Explorar el Código

fix:cbs自动回款修改

duxin hace 7 horas
padre
commit
05ff17f702
Se han modificado 1 ficheros con 12 adiciones y 10 borrados
  1. 12 10
      internal/logic/timedTask/automaticPayment.go

+ 12 - 10
internal/logic/timedTask/automaticPayment.go

@@ -67,12 +67,13 @@ FROM
 	) b ON a.order_code = b.order_code 
 	LEFT JOIN (
 	SELECT
-		order_code,
-		money
-	FROM
-		order_deposi 
-	WHERE
-		state =0 and  is_del=  0 and (pay_money = 0 or pay_money is null)
+    de.order_code,
+    de.money,
+    odp.order_code as payment_order_code
+FROM
+    order_deposit de
+    LEFT JOIN order_deposit_payment odp ON odp.is_del=0 and de.order_code = odp.order_code
+WHERE odp.order_code IS NULL
 	) c ON a.order_code = c.order_code 
 WHERE
 	( a.return_status = 0 OR a.return_status = 2 ) 
@@ -125,18 +126,19 @@ WHERE
 					if status := PaymentPlanMatching(money, gconv.Int(o["deposit_money"]), returnMoney, paymentUser, companyName, remark, remarks, orderCode, filterMap[orderCode].PaybackNum, filterMap[orderCode].paybackListArr, returnOrderMap); status > 0 {
 						if status == 1 || status == 2 { //定金 但定金不是合同金额
 							// 插入定金表
-							_, err := g.DB().Update(ctx, "order_deposi", map[string]interface{}{
+							_, err := g.DB().Insert(ctx, "order_deposit_payment", map[string]interface{}{
+								"order_code":       orderCode,
 								"pay_time":         returnTime,
-								"mold":             3,
+								"pay_way":          3,
 								"operate_time":     time.Now().Format("2006-01-02 15:04:05"),
 								"flow_money":       returnMoney,
 								"pay_money":        returnMoney,
+								"remark":           "自动关联保证金流水",
+								"transaction_id":   id,
 								"bank_name":        BNKNAM,
 								"bank_flow":        BNKFLW,
 								"operate_type":     2,
 								"pay_account_name": paymentUser,
-							}, map[string]interface{}{
-								"order_code": orderCode,
 							})
 							if err != nil {
 								log.Println("定金信息插入失败", id, orderCode, err)