Browse Source

fix:详情修改

duxin 2 weeks ago
parent
commit
9a1a88ffde
1 changed files with 5 additions and 1 deletions
  1. 5 1
      internal/logic/timedTask/automaticPayment.go

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

@@ -46,7 +46,7 @@ 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) as new_pay_money,
+	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.commission+(select IFNULL(sum(commission),0) as return_commission from moneyCorrection where orderCode=a.order_code) as new_commission,
 	b.paybackNum,
 	b.paybackList 
@@ -117,6 +117,10 @@ WHERE
 							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 {
+								log.Printf("回款金额异常,订单:%s回款金额大于实际合同金额\n", orderCode)
+								continue
+							}
 							//isFirstReturn := config.JysqlDB.Count("return_money_record", map[string]interface{}{"state": 1, "order_code": orderCode}) == 0
 							returnReq, _ := g.DB().Insert(ctx, "return_money_record", map[string]interface{}{
 								"order_code":            orderCode,