|
@@ -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(), ¶m)
|
|
|
+ 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))
|
|
|
+}
|