DengBiao пре 1 година
родитељ
комит
086fd65c33
4 измењених фајлова са 73 додато и 42 уклоњено
  1. +10
    -5
      app/admin/hdl/hdl_audit_center.go
  2. +20
    -10
      app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go
  3. +41
    -26
      app/admin/svc/order/svc_central_kitchen_for_school_order.go
  4. +2
    -1
      app/customer/svc/order/svc_central_kitchen_for_school_order.go

+ 10
- 5
app/admin/hdl/hdl_audit_center.go Прегледај датотеку

@@ -6,6 +6,7 @@ import (
svc2 "applet/app/admin/svc/order"
"applet/app/e"
"applet/app/enum"
"applet/app/utils/logx"
"github.com/gin-gonic/gin"
)

@@ -107,11 +108,15 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) {
e.OutErr(c, err1.Code, err1.Error())
return
}
err = svc2.CentralKitchenForSchoolOrderRefundAudit(req)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

go func() {
err1 := svc2.CentralKitchenForSchoolOrderRefundAudit(req)
if err1 != nil {
logx.Error(err1)
println("<<<<CentralKitchenForSchoolOrderRefundAudit>>>>>Error:::", err1.Error())
}
}()

e.OutSuc(c, "success", nil)
return
}


+ 20
- 10
app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go Прегледај датотеку

@@ -831,7 +831,8 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq
now := time.Now()
for _, v := range m {
dealOutTradeNo[v.OrdNo] = v.OrdNo
outRequestNo := utils.OrderUUID(v.Uid)
//outRequestNo := utils.OrderUUID(v.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: v.OrdNo,
OutRequestNo: outRequestNo,
@@ -910,7 +911,8 @@ func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSch
now := time.Now()
for _, m := range mm {
dealOutTradeNo[m.OrdNo] = m.OrdNo
outRequestNo := utils.OrderUUID(m.Uid)
//outRequestNo := utils.OrderUUID(m.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: m.OrdNo,
OutRequestNo: outRequestNo,
@@ -971,7 +973,8 @@ func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSch
now := time.Now()
for _, m := range mm {
dealOutTradeNo[m.OrdNo] = m.OrdNo
outRequestNo := utils.OrderUUID(m.Uid)
//outRequestNo := utils.OrderUUID(m.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: m.OrdNo,
OutRequestNo: outRequestNo,
@@ -1032,7 +1035,8 @@ func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSch
now := time.Now()
for _, m := range mm {
dealOutTradeNo[m.OrdNo] = m.OrdNo
outRequestNo := utils.OrderUUID(m.Uid)
//outRequestNo := utils.OrderUUID(m.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: m.OrdNo,
OutRequestNo: outRequestNo,
@@ -1135,7 +1139,8 @@ func CentralKitchenForSchoolBatchAskForLeaveByGrade(req md.CentralKitchenForScho
now := time.Now()
for _, m := range mm {
dealOutTradeNo[m.OrdNo] = m.OrdNo
outRequestNo := utils.OrderUUID(m.Uid)
//outRequestNo := utils.OrderUUID(m.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: m.OrdNo,
OutRequestNo: outRequestNo,
@@ -1191,7 +1196,8 @@ func CentralKitchenForSchoolBatchAskForLeaveByGrade(req md.CentralKitchenForScho
now := time.Now()
for _, m := range mm {
dealOutTradeNo[m.OrdNo] = m.OrdNo
outRequestNo := utils.OrderUUID(m.Uid)
//outRequestNo := utils.OrderUUID(m.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: m.OrdNo,
OutRequestNo: outRequestNo,
@@ -1247,7 +1253,8 @@ func CentralKitchenForSchoolBatchAskForLeaveByGrade(req md.CentralKitchenForScho
now := time.Now()
for _, m := range mm {
dealOutTradeNo[m.OrdNo] = m.OrdNo
outRequestNo := utils.OrderUUID(m.Uid)
//outRequestNo := utils.OrderUUID(m.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: m.OrdNo,
OutRequestNo: outRequestNo,
@@ -1341,7 +1348,8 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho
now := time.Now()
for _, m := range mm {
dealOutTradeNo[m.OrdNo] = m.OrdNo
outRequestNo := utils.OrderUUID(m.Uid)
//outRequestNo := utils.OrderUUID(m.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: m.OrdNo,
OutRequestNo: outRequestNo,
@@ -1397,7 +1405,8 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho
now := time.Now()
for _, m := range mm {
dealOutTradeNo[m.OrdNo] = m.OrdNo
outRequestNo := utils.OrderUUID(m.Uid)
//outRequestNo := utils.OrderUUID(m.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: m.OrdNo,
OutRequestNo: outRequestNo,
@@ -1453,7 +1462,8 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho
now := time.Now()
for _, m := range mm {
dealOutTradeNo[m.OrdNo] = m.OrdNo
outRequestNo := utils.OrderUUID(m.Uid)
//outRequestNo := utils.OrderUUID(m.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{
OutTradeNo: m.OrdNo,
OutRequestNo: outRequestNo,


+ 41
- 26
app/admin/svc/order/svc_central_kitchen_for_school_order.go Прегледај датотеку

@@ -161,10 +161,18 @@ func CentralKitchenForSchoolOrderRefundAudit(req md.CentralKitchenForSchoolOrder
_ = session.Rollback()
return
}

centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{}
centralKitchenForSchoolUserRefundDayDb.Set(0)
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{}
centralKitchenForSchoolUserWithDayDb.Set(0)
var dealReturnOrdMap map[string]struct {
OutRequestNo string `json:"out_request_no"`
Amount float64 `json:"amount"`
}

outRequestNoSuffix := "_" + utils.Int64ToStr(time.Now().Unix())

for _, v := range req.Ids {
returnDay, err1 := centralKitchenForSchoolUserRefundDayDb.GetCentralKitchenForSchoolUserRefundDay(utils.StrToInt(v))
if err1 != nil {
@@ -185,29 +193,16 @@ func CentralKitchenForSchoolOrderRefundAudit(req md.CentralKitchenForSchoolOrder
if req.State == 1 {
returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditPass
userWithDay.State = enum.CentralKitchenForSchoolUserWithDayStateForCancel
time.Sleep(250 * time.Millisecond) //TODO::避免频繁调用
//调用支付宝进行退款
err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{
Config: struct {
PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"`
PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"`
PayAliPublicKey string `json:"pay_ali_public_key" label:"支付宝开放平台-第三方应用-接口加签-支付宝公钥"`
}{
PayAliAppId: sysCfg[enum.OpenAlipayAppid],
PayAliPrivateKey: sysCfg[enum.OpenAlipayAppPrivateKey],
PayAliPublicKey: sysCfg[enum.OpenAlipayPublicKey],
},
OutTradeNo: returnDay.OutTradeNo,
RefundAmount: returnDay.Amount,
RefundReason: "央厨订餐退款",
OutRequestNo: returnDay.OutRequestNo,
AppAuthToken: sysCfg[enum.JsapiPayAppAutToken],
})
if err6 != nil {
_ = session.Rollback()
return err6
}
outRequestNo := "r" + returnDay.OutRequestNo + outRequestNoSuffix
dealReturnOrdMap[returnDay.OutTradeNo] = struct {
OutRequestNo string `json:"out_request_no"`
Amount float64 `json:"amount"`
}(struct {
OutRequestNo string
Amount float64
}{OutRequestNo: outRequestNo, Amount: dealReturnOrdMap[returnDay.OutTradeNo].Amount + utils.StrToFloat64(returnDay.Amount)})

returnDay.OutRequestNo = outRequestNo
returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete
returnDay.RefundDate = time.Now().Format("2006-01-02 15:04:05")
} else {
@@ -216,7 +211,7 @@ func CentralKitchenForSchoolOrderRefundAudit(req md.CentralKitchenForSchoolOrder
}

returnDay.Memo = req.Memo
updateAck, err2 := centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdate(returnDay.Id, returnDay, "state", "memo", "refund_date")
updateAck, err2 := centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdate(returnDay.Id, returnDay, "state", "memo", "refund_date", "out_request_no")
if err2 != nil {
_ = session.Rollback()
return err2
@@ -244,11 +239,31 @@ func CentralKitchenForSchoolOrderRefundAudit(req md.CentralKitchenForSchoolOrder
_ = session.Rollback()
return err5
}
}

if req.State == 1 {

//调用支付宝进行退款
for k, v := range dealReturnOrdMap {
err6, _ := svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{
Config: struct {
PayAliAppId string `json:"pay_ali_app_id" label:"支付宝开放平台-第三方应用-appid"`
PayAliPrivateKey string `json:"pay_ali_private_key" label:"支付宝开放平台-第三方应用-接口加签-应用私钥"`
PayAliPublicKey string `json:"pay_ali_public_key" label:"支付宝开放平台-第三方应用-接口加签-支付宝公钥"`
}{
PayAliAppId: sysCfg[enum.OpenAlipayAppid],
PayAliPrivateKey: sysCfg[enum.OpenAlipayAppPrivateKey],
PayAliPublicKey: sysCfg[enum.OpenAlipayPublicKey],
},
OutTradeNo: k,
RefundAmount: utils.Float64ToStr(v.Amount),
RefundReason: "央厨订餐退款",
OutRequestNo: v.OutRequestNo,
AppAuthToken: sysCfg[enum.JsapiPayAppAutToken],
})
if err6 != nil {
_ = session.Rollback()
return err6
}
time.Sleep(250 * time.Millisecond) //TODO::避免频繁调用
}

return session.Commit()
}

+ 2
- 1
app/customer/svc/order/svc_central_kitchen_for_school_order.go Прегледај датотеку

@@ -93,7 +93,8 @@ func CentralKitchenForSchoolOrderRefund(req md.CentralKitchenForSchoolOrderRefun
}

//5、新增退款记录 central_kitchen_for_school_user_refund_day
outRequestNo := utils.OrderUUID(centralKitchenForSchoolUserWithDay.Uid)
//outRequestNo := utils.OrderUUID(centralKitchenForSchoolUserWithDay.Uid)
outRequestNo := ""
centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{}
centralKitchenForSchoolUserRefundDayDb.Set(0)
_, err = centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayInsert(&model.CentralKitchenForSchoolUserRefundDay{


Loading…
Откажи
Сачувај