|
@@ -152,10 +152,25 @@ func OperateOrderRedPunch(ctx context.Context, params model.OrderRedPunchParams)
|
|
if refund_money >= params.PayMoney {
|
|
if refund_money >= params.PayMoney {
|
|
updateData["refund_status"] = 1
|
|
updateData["refund_status"] = 1
|
|
}
|
|
}
|
|
- if return_money >= params.PayMoney {
|
|
|
|
|
|
+ // 定金=支付金额 开通权限 修改状态
|
|
|
|
+ // 如果不是全额回款查询已支付保证金金额是否和订单金额相等 如果相等也展示权限开通按钮
|
|
|
|
+ var isDepositFullReturn bool
|
|
|
|
+ if has, err := HasDepositOperate(ctx, params.OrderCode); !has && err == nil { // 验证保证金是否已经有操作记录
|
|
|
|
+ if depositPayMoney, err := GetDepositPayMoney(ctx, params.OrderCode); depositPayMoney > 0 && err == nil { // 判断已支付保证金
|
|
|
|
+ if depositPayMoney == int64(params.PayMoney) {
|
|
|
|
+ isDepositFullReturn = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if return_money >= params.PayMoney || isDepositFullReturn {
|
|
updateData["return_status"] = 1
|
|
updateData["return_status"] = 1
|
|
|
|
+ // 判断是否是退款调用 如果是退款调用生成红冲记录不要开权限 不改订单状态
|
|
if !params.IsRefundCall {
|
|
if !params.IsRefundCall {
|
|
- // 判断是否是退款调用 如果是退款调用生成红冲记录不要开权限
|
|
|
|
|
|
+ if isDepositFullReturn {
|
|
|
|
+ // 如果保证金金额==合同金额 更新订单状态为已完成
|
|
|
|
+ updateData["order_status"] = consts.OrderStatusFinished
|
|
|
|
+ }
|
|
productDetail, _ := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf(`SELECT * FROM jy_order_detail WHERE order_code ='%s' and returned_open =1 and is_service_open = 0 and status =1`, params.OrderCode))
|
|
productDetail, _ := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf(`SELECT * FROM jy_order_detail WHERE order_code ='%s' and returned_open =1 and is_service_open = 0 and status =1`, params.OrderCode))
|
|
if !productDetail.IsEmpty() {
|
|
if !productDetail.IsEmpty() {
|
|
uData, entId, userPositionId, err := jyutil.GetCreateUserData(gconv.String(orderData.Map()["user_phone"]), gconv.String(orderData.Map()["company_name"]), gconv.Int(orderData.Map()["buy_subject"]) == 2)
|
|
uData, entId, userPositionId, err := jyutil.GetCreateUserData(gconv.String(orderData.Map()["user_phone"]), gconv.String(orderData.Map()["company_name"]), gconv.Int(orderData.Map()["buy_subject"]) == 2)
|