duxin 3 месяцев назад
Родитель
Сommit
1f93d2ebaa

+ 1 - 0
internal/cmd/cmd.go

@@ -58,6 +58,7 @@ var (
 					orderGroup.POST("/detail", controller.OrderDetail)                         //订单详情
 					orderGroup.POST("/detail", controller.OrderDetail)                         //订单详情
 					orderGroup.POST("/cancellation", controller.OrderCancellation)             //订单作废
 					orderGroup.POST("/cancellation", controller.OrderCancellation)             //订单作废
 					orderGroup.POST("/editBatchReturn", controller.OrderEditBatchReturn)       //订单回款
 					orderGroup.POST("/editBatchReturn", controller.OrderEditBatchReturn)       //订单回款
+					orderGroup.POST("/surplusPrice", controller.OrderSurplusPrice)             //订单剩余回款计算
 					orderGroup.POST("/orderRedPunch", controller.OrderRedPunch)                //订单红冲
 					orderGroup.POST("/orderRedPunch", controller.OrderRedPunch)                //订单红冲
 					orderGroup.POST("/refund", controller.OrderRefund)                         //订单退款
 					orderGroup.POST("/refund", controller.OrderRefund)                         //订单退款
 					orderGroup.POST("/seal", controller.OrderSeal)                             //订单盖章
 					orderGroup.POST("/seal", controller.OrderSeal)                             //订单盖章

+ 36 - 0
internal/controller/orderSurplusPrice.go

@@ -0,0 +1,36 @@
+package controller
+
+import (
+	. "app.yhyue.com/moapp/jybase/api"
+	"app.yhyue.com/moapp/jybase/common"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/net/ghttp"
+	"github.com/gogf/gf/v2/util/gconv"
+	"github.com/pkg/errors"
+	"jyOrderManager/internal/model"
+)
+
+// OrderSurplusPrice 订单详情
+func OrderSurplusPrice(r *ghttp.Request) {
+	rData, err := func() (interface{}, error) {
+		var param model.OrdersEditBatchReturn
+		err := gconv.Struct(r.GetBody(), &param)
+		if err != nil {
+			return nil, errors.Wrap(err, "数据校验异常")
+		}
+		var price int
+		for key, value := range param.OrderArr {
+			orderData, _ := g.DB().GetOne(r.Context(), "select  (IFNULL( a.pay_money, 0 )-IFNULL(a.commission,0)-IFNULL(a.procedures_money,0))-(select  IFNULL(sum(b.return_money),0) from  return_money_record  b where b.order_code=a.order_code and  b.state=1) + (select  IFNULL(sum(c.refund_money),0) from refund_record c where c.order_code=a.order_code)+(select IFNULL(sum(payMoney),0) as return_money from moneyCorrection c where c.orderCode=a.order_code) as outstandingPayment, a.*  from  dataexport_order a where  a.id=?", value["orderId"])
+			if orderData.IsEmpty() {
+				continue
+			}
+			param.OrderArr[key]["money"] = common.IntAll(orderData.Map()["outstandingPayment"])
+			price += common.IntAll(orderData.Map()["outstandingPayment"])
+		}
+		return map[string]interface{}{"status": true, "orderArr": param.OrderArr, "price": price}, nil
+	}()
+	if err != nil {
+		g.Log().Errorf(r.Context(), "订单详情异常 %v", err)
+	}
+	r.Response.WriteJson(NewResult(rData, err))
+}

+ 1 - 1
internal/controller/orderdetail.go

@@ -10,7 +10,7 @@ import (
 	"jyOrderManager/internal/model"
 	"jyOrderManager/internal/model"
 )
 )
 
 
-// OrderDetail 订单详情
+// OrderSurplusPrice 订单剩余回款计算
 func OrderDetail(r *ghttp.Request) {
 func OrderDetail(r *ghttp.Request) {
 	rData, err := func() (interface{}, error) {
 	rData, err := func() (interface{}, error) {
 		var param model.OrderDetailParams
 		var param model.OrderDetailParams

+ 1 - 1
internal/logic/order/editBatchReturn.go

@@ -43,7 +43,7 @@ func EditBatchReturn(ctx context.Context, param model.OrdersEditBatchReturn) err
 	)
 	)
 
 
 	for _, value := range param.OrderArr {
 	for _, value := range param.OrderArr {
-		orderData, _ := g.DB().Ctx(ctx).GetOne(ctx, "select  (IFNULL( a.pay_money, 0 )-IFNULL(a.commission,0)-IFNULL(a.procedures_money,0))-(select  IFNULL(sum(b.return_money),0) from  return_money_record  b where b.order_code=a.order_code and  b.state=1) + (select  IFNULL(sum(c.refund_money),0) from refund_record c where c.order_code=a.order_code) as outstandingPayment, a.*  from  dataexport_order a where  a.id=?", value["orderId"])
+		orderData, _ := g.DB().Ctx(ctx).GetOne(ctx, "select  (IFNULL( a.pay_money, 0 )-IFNULL(a.commission,0)-IFNULL(a.procedures_money,0))-(select  IFNULL(sum(b.return_money),0) from  return_money_record  b where b.order_code=a.order_code and  b.state=1) + (select  IFNULL(sum(c.refund_money),0) from refund_record c where c.order_code=a.order_code)+(select IFNULL(sum(payMoney),0) as return_money from moneyCorrection c where c.orderCode=a.order_code) as outstandingPayment, a.*  from  dataexport_order a where  a.id=?", value["orderId"])
 		if orderData.IsEmpty() {
 		if orderData.IsEmpty() {
 			continue
 			continue
 		}
 		}

+ 13 - 3
internal/logic/user/getService.go

@@ -181,7 +181,11 @@ WHERE a.status = 1  and b.user_phone = ? and a.product_type like '%大会员%' O
 					})
 					})
 				} else {
 				} else {
 					if !entRec.IsEmpty() {
 					if !entRec.IsEmpty() {
-						serviceArrMap = append(serviceArrMap, userEntService(ctx, gconv.String(entRec.Map()["id"]), whereEntTime, "%大会员%"))
+						uData := userEntService(ctx, gconv.String(entRec.Map()["id"]), whereEntTime, "%大会员%")
+						if uData != nil {
+							serviceArrMap = append(serviceArrMap, uData)
+						}
+
 					}
 					}
 				}
 				}
 			case "VIP订阅":
 			case "VIP订阅":
@@ -245,11 +249,17 @@ WHERE a.status = 1 and b.user_phone = ? and a.product_type like '%VIP订阅%' OR
 					})
 					})
 				} else {
 				} else {
 					if !entRec.IsEmpty() {
 					if !entRec.IsEmpty() {
-						serviceArrMap = append(serviceArrMap, userEntService(ctx, gconv.String(entRec.Map()["id"]), whereEntTime, "%VIP订阅%"))
+						uData := userEntService(ctx, gconv.String(entRec.Map()["id"]), whereEntTime, "%VIP订阅%")
+						if uData != nil {
+							serviceArrMap = append(serviceArrMap, uData)
+						}
 					}
 					}
 				}
 				}
 			default:
 			default:
-				serviceArrMap = append(serviceArrMap, SpecialService(ctx, whereSql, gconv.String(m["product_type"]), gconv.Int(param.BuySubject)))
+				uData := SpecialService(ctx, whereSql, gconv.String(m["product_type"]), gconv.Int(param.BuySubject))
+				if uData != nil {
+					serviceArrMap = append(serviceArrMap, uData)
+				}
 			}
 			}
 		}
 		}
 	}
 	}