新增了药品订单取消增加order表取消。新增了服务包订单取消关联问诊订单取消
This commit is contained in:
parent
1bd908c79f
commit
52888553bf
@ -247,7 +247,7 @@ func (r *OrderInquiryService) CancelOrderInquiry(req requests.CancelOrderInquiry
|
|||||||
}
|
}
|
||||||
|
|
||||||
if refundStatus == 3 && !successTime.IsZero() {
|
if refundStatus == 3 && !successTime.IsZero() {
|
||||||
orderRefund.SuccessTime = model.LocalTime(successTime)
|
orderInquiryRefund.SuccessTime = model.LocalTime(successTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
orderInquiryRefundDao := dao.OrderInquiryRefundDao{}
|
orderInquiryRefundDao := dao.OrderInquiryRefundDao{}
|
||||||
|
|||||||
@ -233,6 +233,19 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 修改订单为取消
|
||||||
|
orderData := make(map[string]interface{})
|
||||||
|
orderData["cancel_status"] = 1
|
||||||
|
orderData["cancel_time"] = time.Now().Format("2006-01-02 15:04:05")
|
||||||
|
orderData["cancel_remarks"] = req.CancelRemarks
|
||||||
|
|
||||||
|
orderDao := dao.OrderDao{}
|
||||||
|
err = orderDao.EditOrderById(tx, orderProduct.OrderId, orderData)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("取消订单失败")
|
||||||
|
}
|
||||||
|
|
||||||
// 修改问诊订单退款状态
|
// 修改问诊订单退款状态
|
||||||
orderProductData["refund_status"] = refundStatus
|
orderProductData["refund_status"] = refundStatus
|
||||||
orderProductData["order_product_status"] = 5 // 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
orderProductData["order_product_status"] = 5 // 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||||
@ -246,6 +259,29 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct
|
|||||||
return false, errors.New("取消订单失败")
|
return false, errors.New("取消订单失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增退款表
|
||||||
|
orderRefund := &model.OrderRefund{
|
||||||
|
OrderId: orderProduct.OrderId,
|
||||||
|
PatientId: orderProduct.PatientId,
|
||||||
|
OrderNo: orderProduct.OrderProductNo,
|
||||||
|
RefundNo: refundNo,
|
||||||
|
RefundId: refundId,
|
||||||
|
RefundStatus: refundStatus,
|
||||||
|
RefundTotal: orderProduct.PaymentAmountTotal,
|
||||||
|
RefundReason: req.CancelRemarks,
|
||||||
|
}
|
||||||
|
|
||||||
|
if refundStatus == 3 && !successTime.IsZero() {
|
||||||
|
orderRefund.SuccessTime = model.LocalTime(successTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
orderRefundDao := dao.OrderRefundDao{}
|
||||||
|
orderRefund, err = orderRefundDao.AddOrderRefund(tx, orderRefund)
|
||||||
|
if err != nil || orderRefund == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// 新增退款表
|
// 新增退款表
|
||||||
orderProductRefund := &model.OrderProductRefund{
|
orderProductRefund := &model.OrderProductRefund{
|
||||||
PatientId: orderProduct.PatientId,
|
PatientId: orderProduct.PatientId,
|
||||||
@ -256,7 +292,10 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct
|
|||||||
ProductRefundStatus: refundStatus,
|
ProductRefundStatus: refundStatus,
|
||||||
RefundTotal: orderProduct.PaymentAmountTotal,
|
RefundTotal: orderProduct.PaymentAmountTotal,
|
||||||
RefundReason: req.CancelRemarks,
|
RefundReason: req.CancelRemarks,
|
||||||
SuccessTime: model.LocalTime(successTime),
|
}
|
||||||
|
|
||||||
|
if refundStatus == 3 && !successTime.IsZero() {
|
||||||
|
orderProductRefund.SuccessTime = model.LocalTime(successTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
orderProductRefundDao := dao.OrderProductRefundDao{}
|
orderProductRefundDao := dao.OrderProductRefundDao{}
|
||||||
|
|||||||
@ -344,7 +344,7 @@ func (r *OrderServicePackageService) CancelOrderServicePackage(req requests.Canc
|
|||||||
}
|
}
|
||||||
|
|
||||||
if refundStatus == 3 && !successTime.IsZero() {
|
if refundStatus == 3 && !successTime.IsZero() {
|
||||||
orderRefund.SuccessTime = model.LocalTime(successTime)
|
orderServicePackageRefund.SuccessTime = model.LocalTime(successTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
orderServicePackageRefundDao := dao.OrderServicePackageRefundDao{}
|
orderServicePackageRefundDao := dao.OrderServicePackageRefundDao{}
|
||||||
@ -354,6 +354,131 @@ func (r *OrderServicePackageService) CancelOrderServicePackage(req requests.Canc
|
|||||||
return false, errors.New(err.Error())
|
return false, errors.New(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取服务包关联问诊订单
|
||||||
|
for _, inquiry := range orderServicePackage.OrderServicePackageInquiry {
|
||||||
|
// 获取订单数据
|
||||||
|
orderInquiryDao := dao.OrderInquiryDao{}
|
||||||
|
orderInquiry, err := orderInquiryDao.GetOrderInquiryById(inquiry.OrderInquiryId)
|
||||||
|
if err != nil || orderInquiry == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("取消订单失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测订单状态 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
if orderInquiry.InquiryStatus == 6 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测订单状态 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
if orderInquiry.InquiryStatus == 7 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支付金额为0,模拟退款
|
||||||
|
refundId = "模拟退款:" + strconv.FormatInt(global.Snowflake.Generate().Int64(), 10)
|
||||||
|
refundStatus = 3
|
||||||
|
successTime = time.Now()
|
||||||
|
|
||||||
|
// 模拟退款时手动退还优惠卷
|
||||||
|
if orderInquiry.CouponAmountTotal > 0 {
|
||||||
|
orderService := OrderService{}
|
||||||
|
res, err := orderService.ReturnOrderCoupon(orderInquiry.InquiryNo, tx)
|
||||||
|
if err != nil || !res {
|
||||||
|
// 退还优惠卷失败
|
||||||
|
tx.Rollback()
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改订单为取消
|
||||||
|
orderData := make(map[string]interface{})
|
||||||
|
orderData["cancel_status"] = 1
|
||||||
|
orderData["cancel_time"] = time.Now().Format("2006-01-02 15:04:05")
|
||||||
|
orderData["cancel_remarks"] = req.CancelRemarks
|
||||||
|
|
||||||
|
orderDao := dao.OrderDao{}
|
||||||
|
err = orderDao.EditOrderById(tx, orderInquiry.OrderId, orderData)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("取消订单失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改问诊订单为取消
|
||||||
|
orderInquiryData := make(map[string]interface{})
|
||||||
|
orderInquiryData["inquiry_status"] = 7 // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
orderInquiryData["cancel_time"] = time.Now().Format("2006-01-02 15:04:05") // 订单取消时间
|
||||||
|
orderInquiryData["cancel_reason"] = 4 // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||||
|
orderInquiryData["cancel_remarks"] = req.CancelRemarks // 取消订单备注(自动添加)
|
||||||
|
err = orderInquiryDao.EditOrderInquiryById(tx, orderInquiry.OrderInquiryId, orderInquiryData)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("取消订单失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增退款表
|
||||||
|
orderRefund := &model.OrderRefund{
|
||||||
|
OrderId: orderInquiry.OrderId,
|
||||||
|
PatientId: orderInquiry.PatientId,
|
||||||
|
OrderNo: orderInquiry.InquiryNo,
|
||||||
|
RefundNo: refundNo,
|
||||||
|
RefundId: refundId,
|
||||||
|
RefundStatus: refundStatus,
|
||||||
|
RefundTotal: *req.RefundAmount,
|
||||||
|
RefundReason: req.CancelRemarks,
|
||||||
|
}
|
||||||
|
|
||||||
|
if refundStatus == 3 && !successTime.IsZero() {
|
||||||
|
orderRefund.SuccessTime = model.LocalTime(successTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
orderRefundDao := dao.OrderRefundDao{}
|
||||||
|
orderRefund, err = orderRefundDao.AddOrderRefund(tx, orderRefund)
|
||||||
|
if err != nil || orderRefund == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增问诊退款表
|
||||||
|
orderInquiryRefund := &model.OrderInquiryRefund{
|
||||||
|
PatientId: orderInquiry.PatientId,
|
||||||
|
OrderInquiryId: orderInquiry.OrderInquiryId,
|
||||||
|
InquiryNo: orderInquiry.InquiryNo,
|
||||||
|
InquiryRefundNo: refundNo,
|
||||||
|
RefundId: refundId,
|
||||||
|
InquiryRefundStatus: refundStatus,
|
||||||
|
RefundTotal: *req.RefundAmount,
|
||||||
|
RefundReason: req.CancelRemarks,
|
||||||
|
SuccessTime: model.LocalTime(successTime),
|
||||||
|
}
|
||||||
|
|
||||||
|
if refundStatus == 3 && !successTime.IsZero() {
|
||||||
|
orderInquiryRefund.SuccessTime = model.LocalTime(successTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
orderInquiryRefundDao := dao.OrderInquiryRefundDao{}
|
||||||
|
orderInquiryRefund, err = orderInquiryRefundDao.AddOrderInquiryRefund(tx, orderInquiryRefund)
|
||||||
|
if err != nil || orderInquiryRefund == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录日志
|
||||||
|
orderOperationLog := &model.OrderOperationLog{
|
||||||
|
OrderId: orderInquiry.OrderId,
|
||||||
|
OrderNo: orderInquiry.InquiryNo,
|
||||||
|
OrderType: 1,
|
||||||
|
OperatorId: adminUserId,
|
||||||
|
OperationContent: "服务包关联取消订单",
|
||||||
|
}
|
||||||
|
|
||||||
|
orderOperationLogDao := dao.OrderOperationLogDao{}
|
||||||
|
orderOperationLog, err = orderOperationLogDao.AddOrderOperationLog(tx, orderOperationLog)
|
||||||
|
if err != nil || orderOperationLog == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
orderOperationLog := &model.OrderOperationLog{
|
orderOperationLog := &model.OrderOperationLog{
|
||||||
OrderId: orderServicePackage.OrderId,
|
OrderId: orderServicePackage.OrderId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user