소스 검색

fix:详情修改

duxin 2 주 전
부모
커밋
cac969164e
1개의 변경된 파일5개의 추가작업 그리고 6개의 파일을 삭제
  1. 5 6
      internal/logic/timedTask/automaticPayment.go

+ 5 - 6
internal/logic/timedTask/automaticPayment.go

@@ -46,7 +46,9 @@ func AutomaticPayment() {
 		returnOrderMap := make(map[string]int)
 		orderData, _ := g.DB().Query(ctx, `SELECT
 	a.*,
-	a.pay_money+(select IFNULL(sum(payMoney),0) as return_money from moneyCorrection where orderCode=a.order_code)+ (select  IFNULL(sum(c.refund_money),0)  as refund_money from refund_record c where c.order_code=a.order_code) as new_pay_money,
+	a.pay_money+(select IFNULL(sum(payMoney),0) as return_money from moneyCorrection where orderCode=a.order_code)as new_pay_money,
+	(select  IFNULL(sum(c.refund_money),0)  as refund_money from refund_record c where c.order_code=a.order_code)  as refund_money,
+	(SELECT SUM(r.return_money) as returned_money  FROM return_money_record r WHERE r.order_code=a.order_code AND state=1) as returned_money,
 	a.commission+(select IFNULL(sum(commission),0) as return_commission from moneyCorrection where orderCode=a.order_code) as new_commission,
 	b.paybackNum,
 	b.paybackList 
@@ -113,11 +115,8 @@ WHERE
 						isExists, err := g.Redis("qmx_filter").Exists(ctx, "qmx_auto_return_"+fmt.Sprint(id))
 						if isExists == 0 || err != nil {
 							log.Println("自动回款匹配成功", id, orderCode)
-							var returned_money int
-							if calculation, _ := g.DB().GetOne(ctx, fmt.Sprintf("SELECT SUM(return_money) as returned_money  FROM return_money_record WHERE order_code=%s AND state=1", orderCode)); !calculation.IsEmpty() {
-								returned_money = gconv.Int(calculation.Map()["returned_money"])
-							}
-							if returned_money+returnMoney > money {
+							returned_money := gconv.Int(o["returned_money"])
+							if returned_money+returnMoney > money+gconv.Int(o["refund_money"]) {
 								log.Printf("回款金额异常,订单:%s回款金额大于实际合同金额\n", orderCode)
 								continue
 							}