@@ -1323,6 +1323,25 @@ func SelfSupportForSchoolOrdRefund(c *gin.Context) { | |||
return | |||
} | |||
func SelfSupportForSchoolOrdPartRefund(c *gin.Context) { | |||
var req md.SelfSupportForSchoolOrdPartRefundReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
err = svc2.SelfSupportForSchoolOrdPartRefund(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func CentralKitchenForSchoolBatchAskForLeave(c *gin.Context) { | |||
//TODO:: 加锁 Redis 锁,防并发 | |||
getString, _ := cache.GetString(md.BatchAskForLeaveLockKeyForCentralKitchen) | |||
@@ -1116,6 +1116,10 @@ func SelfSupportForSchoolOrdList(c *gin.Context) { | |||
"name": enum.SelfSupportForSchoolOrdOrderStatus.String(enum.SelfSupportForSchoolOrdOrderStatusForCancel), | |||
"value": enum.SelfSupportForSchoolOrdOrderStatusForCancel, | |||
}, | |||
{ | |||
"name": enum.SelfSupportForSchoolOrdOrderStatus.String(enum.SelfSupportForSchoolOrdOrderStatusForPartRefund), | |||
"value": enum.SelfSupportForSchoolOrdOrderStatusForPartRefund, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
@@ -23,20 +23,27 @@ import ( | |||
// Demo 测试 | |||
func Demo(c *gin.Context) { | |||
eg := db.Db | |||
var mm []model.UserIdentity | |||
if err1 := eg.Where("state = 1").Asc("id").Find(&mm); err1 != nil { | |||
var mm []model.CentralKitchenForSchoolPackageOrdForReserve | |||
if err1 := eg.Asc("id").Find(&mm); err1 != nil { | |||
e.OutErr(c, e.ERR, err1.Error()) | |||
return | |||
} | |||
for _, v := range mm { | |||
var m []model.CentralKitchenForSchoolUserWithDay | |||
if err1 := eg.Where("identity_id = ?", v.Id).And("state =1 and enterprise_id !=?", v.EnterpriseId).Find(&m); err1 != nil { | |||
e.OutErr(c, e.ERR, err1.Error()) | |||
m := new(model.CentralKitchenForSchoolUserWithDay) | |||
has, err := db.Db.Where("ord_no =?", v.OutTradeNo).Get(m) | |||
if err != nil { | |||
fmt.Println(err) | |||
return | |||
} | |||
if len(m) > 0 { | |||
if !has { | |||
utils.FilePutContents("demo_demo", utils.SerializeStr(v)) | |||
} | |||
if m.IdentityId != v.UserIdentityId { | |||
utils.FilePutContents("demo", utils.SerializeStr(v)) | |||
} | |||
if m.EnterpriseId != v.EnterpriseId { | |||
utils.FilePutContents("demo111", utils.SerializeStr(v)) | |||
} | |||
} | |||
return | |||
var m []model.CentralKitchenForSchoolUserWithDay | |||
@@ -127,6 +134,121 @@ func Demo(c *gin.Context) { | |||
return | |||
} | |||
// Demo 测试 | |||
func TempDemo(c *gin.Context) { | |||
eg := db.Db | |||
var list []*model.CentralKitchenForSchoolUserWithDay | |||
err := db.Db.Where("state = 3").Asc("id").Find(&list) | |||
if err != nil { | |||
return | |||
} | |||
for _, m := range list { | |||
mm := new(model.CentralKitchenForSchoolUserRefundDay) | |||
has, err := db.Db.Where("records_id =? and state = 4", m.Id).Get(mm) | |||
if err != nil { | |||
fmt.Println(err) | |||
return | |||
} | |||
if has { | |||
m.State = 4 | |||
updateAffetcd, err := db.Db.Where("id =?", m.Id).Cols("state").Update(m) | |||
if err != nil { | |||
fmt.Println(err) | |||
return | |||
} | |||
fmt.Println(">>>>>>>>>>>", updateAffetcd) | |||
} | |||
} | |||
return | |||
var m []model.CentralKitchenForSchoolUserWithDay | |||
if err1 := eg.Where("state = 3").Asc("id").Find(&m); err1 != nil { | |||
e.OutErr(c, e.ERR, err1.Error()) | |||
return | |||
} | |||
now := time.Now() | |||
var records []int | |||
for _, v := range m { | |||
mm := new(model.CentralKitchenForSchoolUserRefundDay) | |||
has, err := db.Db.Where("records_id =? and state = 1", v.Id).Get(mm) | |||
if err != nil { | |||
fmt.Println(err) | |||
return | |||
} | |||
if has == false { | |||
centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{} | |||
centralKitchenForSchoolUserRefundDayDb.Set(0) | |||
_, err = centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayInsert(&model.CentralKitchenForSchoolUserRefundDay{ | |||
OutTradeNo: v.OrdNo, | |||
OutRequestNo: "", | |||
Uid: v.Uid, | |||
IdentityId: v.IdentityId, | |||
RecordsId: v.Id, | |||
State: enum.CentralKitchenForSchoolUserRefundDayStateForAuditing, | |||
Amount: v.Amount, | |||
Memo: "fill", | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
records = append(records, v.Id) | |||
} | |||
} | |||
e.OutSuc(c, records, nil) | |||
return | |||
var req md.CentralKitchenForSchoolOrderRefundAuditReq | |||
err = c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
err1 := svc.CentralKitchenForSchoolOrderRefundAudit(c, req) | |||
if err1 != nil { | |||
fmt.Println(err1.Error()) | |||
e.OutErr(c, e.ERR, err1.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
sysCfgDb := db.SysCfgDb{} | |||
sysCfgDb.Set() | |||
sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAlipayAppid, enum.OpenAlipayAppPrivateKey, enum.OpenAlipayPublicKey) | |||
//调用支付宝进行退款 | |||
err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{ | |||
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: "800169659125681442", | |||
RefundAmount: "180.00", | |||
RefundReason: "央厨订餐退款", | |||
OutRequestNo: "r_800169659125681442_1705546121", | |||
AppAuthToken: "202308BB8ef30019cd8d4a40a3853192c397dX35", | |||
}) | |||
if err6 != nil { | |||
fmt.Println(err6.Error()) | |||
} | |||
return | |||
qrcodeWithBatchRecordsDb := db.AdminDb{} | |||
qrcodeWithBatchRecordsDb.Set() | |||
data, _, err := qrcodeWithBatchRecordsDb.GetAdminRolePermission(1001) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, data, nil) | |||
go GoOnExecuting() | |||
return | |||
} | |||
func DemoV1(c *gin.Context) { | |||
var outRequestNo = c.Query("out_request_no") | |||
var outTradeNo = c.Query("out_no") | |||
@@ -218,6 +218,12 @@ type SelfSupportForSchoolOrdRefundReq struct { | |||
Ids []string `json:"ids" label:"ids" binding:"required"` | |||
} | |||
type SelfSupportForSchoolOrdPartRefundReq struct { | |||
EnterpriseId int `json:"enterprise_id" label:"企业id"` | |||
Id string `json:"id" label:"id" binding:"required"` | |||
RefundAmount string `json:"refund_amount" label:"退款金额" binding:"required"` | |||
} | |||
type CentralKitchenForSchoolOrdListResp struct { | |||
EnterpriseId int `json:"enterprise_id" ` | |||
EnterpriseName string `json:"enterprise_name" ` | |||
@@ -1344,8 +1344,68 @@ func SelfSupportForSchoolOrdRefund(req md.SelfSupportForSchoolOrdRefundReq) (err | |||
//3、修改 self_support_for_school_ord 的 `order_status` 字段 | |||
selfSupportForSchoolOrd.Set(v.OutOrderNo) | |||
v.RefundAmount = v.TradeAmount | |||
v.OrderStatus = enum2.SelfSupportForSchoolOrdOrderStatusForRefund | |||
selfSupportForSchoolOrd.SelfSupportForSchoolOrdUpdate(&v, "order_status") | |||
selfSupportForSchoolOrd.SelfSupportForSchoolOrdUpdate(&v, "order_status", "refund_amount") | |||
} | |||
return | |||
} | |||
func SelfSupportForSchoolOrdPartRefund(req md.SelfSupportForSchoolOrdPartRefundReq) (err error) { | |||
//1、查询出所有 `self_support_for_school_ord` 记录 | |||
var m []model.SelfSupportForSchoolOrd | |||
selfSupportForSchoolOrd := db.SelfSupportForSchoolOrd{} | |||
selfSupportForSchoolOrd.Set("") | |||
err = selfSupportForSchoolOrd.Db. | |||
Where("order_status = ?", enum2.SelfSupportForSchoolOrdOrderStatusForSuccess). | |||
In("id", req.Id).Find(&m) | |||
if err != nil { | |||
return err | |||
} | |||
//sysCfgDb := db.SysCfgDb{} | |||
//sysCfgDb.Set() | |||
//sysCfg := sysCfgDb.SysCfgFindWithDb(enum2.OpenAlipayAppid, enum2.OpenAlipayAppPrivateKey, enum2.OpenAlipayPublicKey) | |||
companyWithAlipayAppAuthTokenDb := db.CompanyWithAlipayAppAuthTokenDb{} | |||
companyWithAlipayAppAuthTokenDb.Set() | |||
companyDb := db.EnterpriseDb{} | |||
companyDb.Set() | |||
for _, v := range m { | |||
//1、公司-支付宝应用授权 记录 | |||
enterprise, err1 := companyDb.GetEnterprise(v.EnterpriseId) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
if enterprise == nil { | |||
continue | |||
} | |||
companyWithAlipayAppAuthToken, err1 := companyWithAlipayAppAuthTokenDb.GetCoWithAlipayAppAuthToken(enterprise.CompanyId) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
if companyWithAlipayAppAuthToken == nil { | |||
continue | |||
} | |||
//2、支付宝进行退款 | |||
err1, _ = svc2.CurlAlipayTradeRefund(md2.CurlAlipayTradeRefundReq{ | |||
OutOrderNo: v.OutOrderNo, | |||
RefundAmount: req.RefundAmount, | |||
RefundReason: "刷脸就餐-部分退款", | |||
RefundOutOrderNo: utils.OrderUUID(v.Uid), | |||
MerchantCode: v.CpMerchantId, | |||
}) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
//3、修改 self_support_for_school_ord 的 `order_status` 字段 | |||
selfSupportForSchoolOrd.Set(v.OutOrderNo) | |||
v.RefundAmount = v.TradeAmount | |||
v.OrderStatus = enum2.SelfSupportForSchoolOrdOrderStatusForPartRefund | |||
selfSupportForSchoolOrd.SelfSupportForSchoolOrdUpdate(&v, "order_status", "refund_amount") | |||
} | |||
return | |||
@@ -81,6 +81,10 @@ func SelfSupportForSchoolOrderList(c *gin.Context) { | |||
"name": enum.SelfSupportForSchoolOrdOrderStatus.String(enum.SelfSupportForSchoolOrdOrderStatusForCancel), | |||
"value": enum.SelfSupportForSchoolOrdOrderStatusForCancel, | |||
}, | |||
{ | |||
"name": enum.SelfSupportForSchoolOrdOrderStatus.String(enum.SelfSupportForSchoolOrdOrderStatusForPartRefund), | |||
"value": enum.SelfSupportForSchoolOrdOrderStatusForPartRefund, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
@@ -19,6 +19,7 @@ type SelfSupportForSchoolOrd struct { | |||
MerchantName string `json:"merchant_name" xorm:"not null default '' comment('商户名称') CHAR(100)"` | |||
CpMerchantId string `json:"cp_merchant_id" xorm:"not null default '' comment('商户编码') CHAR(100)"` | |||
TradeAmount string `json:"trade_amount" xorm:"not null default 0.00 comment('交易总金额') DECIMAL(8,2)"` | |||
RefundAmount string `json:"refund_amount" xorm:"not null default 0.00 comment('退款金额') DECIMAL(8,2)"` | |||
FaceTime string `json:"face_time" xorm:"not null default '' comment('刷脸时间') CHAR(100)"` | |||
PayTime string `json:"pay_time" xorm:"not null default '' comment('付款时间') CHAR(100)"` | |||
OrderStatus int `json:"order_status" xorm:"not null default 0 comment('支付状态 (1:待支付 2:支付成功 3:已退款)') TINYINT(1)"` | |||
@@ -3,10 +3,11 @@ package enum | |||
type SelfSupportForSchoolOrdOrderStatus int32 | |||
const ( | |||
SelfSupportForSchoolOrdOrderStatusForWait = 1 | |||
SelfSupportForSchoolOrdOrderStatusForSuccess = 2 | |||
SelfSupportForSchoolOrdOrderStatusForRefund = 3 | |||
SelfSupportForSchoolOrdOrderStatusForCancel = 4 | |||
SelfSupportForSchoolOrdOrderStatusForWait = 1 | |||
SelfSupportForSchoolOrdOrderStatusForSuccess = 2 | |||
SelfSupportForSchoolOrdOrderStatusForRefund = 3 | |||
SelfSupportForSchoolOrdOrderStatusForCancel = 4 | |||
SelfSupportForSchoolOrdOrderStatusForPartRefund = 5 | |||
) | |||
func (gt SelfSupportForSchoolOrdOrderStatus) String() string { | |||
@@ -19,6 +20,8 @@ func (gt SelfSupportForSchoolOrdOrderStatus) String() string { | |||
return "已退款" | |||
case SelfSupportForSchoolOrdOrderStatusForCancel: | |||
return "已撤销" | |||
case SelfSupportForSchoolOrdOrderStatusForPartRefund: | |||
return "部分退款" | |||
default: | |||
return "未知" | |||
} | |||
@@ -103,6 +103,7 @@ func rFinanceManage(r *gin.RouterGroup) { | |||
r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //财务管理-(央厨-学校)订单退款 | |||
r.POST("/selfSupportForSchool/ordList", hdl.SelfSupportForSchoolOrdList) //财务管理-(自营-学校)订单列表 | |||
r.POST("/selfSupportForSchool/ordRefund", hdl.SelfSupportForSchoolOrdRefund) //财务管理-(自营-学校)订单退款 | |||
r.POST("/selfSupportForSchool/ordPartRefund", hdl.SelfSupportForSchoolOrdPartRefund) //财务管理-(自营-学校)订单部分退款 | |||
r.POST("/selfSupportForSchool/arrearsOrdList", hdl.SelfSupportForSchoolArrearsOrdList) //财务管理-(自营-学校)欠费列表 | |||
r.POST("/selfSupportForSchool/arrearsOrdDebtRepay", hdl.SelfSupportForSchoolArrearsOrdDebtRepay) //"自营-学校"订单欠费催缴 | |||
r.POST("/selfSupportForSchool/arrearsOrdDebtCancel", hdl.SelfSupportForSchoolArrearsOrdDebtCancel) //"自营-学校"撤销欠款 | |||
@@ -237,6 +238,7 @@ func rEnterpriseManage(r *gin.RouterGroup) { | |||
r.GET("/selfSupportForSchool/downloadTemplateExcel", hdl.SelfSupportForSchoolDownloadTemplateExcel) //"自营-学校"下载表格模板 | |||
r.POST("/selfSupportForSchool/ordList", hdl.SelfSupportForSchoolOrdList) //"自营-学校"订单列表 | |||
r.POST("/selfSupportForSchool/ordRefund", hdl.SelfSupportForSchoolOrdRefund) //财务管理-(自营-学校)订单退款 | |||
r.POST("/selfSupportForSchool/ordPartRefund", hdl.SelfSupportForSchoolOrdPartRefund) //财务管理-(自营-学校)订单部分退款 | |||
r.Any("/selfSupportForSchool/ordListExport", hdl.SelfSupportForSchoolOrdListExport) //"自营-学校"订单列表-导出 | |||
r.POST("/selfSupportForSchool/consumeLimit", hdl.SelfSupportForSchoolConsumeLimit) //"自营-学校"消费限制-编辑 | |||
r.POST("/selfSupportForSchool/consumeLimitList", hdl.SelfSupportForSchoolConsumeLimitList) //"自营-学校"消费限制-列表 | |||
@@ -292,6 +294,7 @@ func rRole(r *gin.RouterGroup) { | |||
func AdminRoute(r *gin.RouterGroup) { | |||
r.GET("/demo", hdl2.Demo) | |||
r.GET("/tmpDemo", hdl2.TempDemo) | |||
r.GET("/test", hdl2.DemoV1) | |||
r.POST("/login", hdl2.Login) | |||