差评补款
This commit is contained in:
@@ -770,6 +770,9 @@ func GetOrdersSupplement(ctx *jxcontext.Context, storIDs, vendorIDs []int, vendo
|
||||
if toTime != "" {
|
||||
toTimeP = utils.Str2Time(toTime)
|
||||
}
|
||||
if fromTimeP.After(toTimeP) {
|
||||
return nil, fmt.Errorf("时间范围不合法!开始时间:[%v],结束时间:[%v]", fromTimeP, toTimeP)
|
||||
}
|
||||
result, totalCount, err := dao.GetOrdersSupplement(db, storIDs, vendorIDs, vendorOrderID, fromTimeP, toTimeP, status, stype, offset, pageSize)
|
||||
pageInfo = &model.PagedInfo{
|
||||
Data: result,
|
||||
@@ -778,18 +781,37 @@ func GetOrdersSupplement(ctx *jxcontext.Context, storIDs, vendorIDs []int, vendo
|
||||
return pageInfo, err
|
||||
}
|
||||
|
||||
func AddUpdateOrdersSupplement(ctx *jxcontext.Context, ordersSupplement *model.OrderSupplementFee) (num int, err error) {
|
||||
// var (
|
||||
// db = dao.GetDB()
|
||||
// id = ordersSupplement.ID
|
||||
// )
|
||||
// if id > 0 {
|
||||
// if ordersSupplement.Status == 1 {
|
||||
// return 0,fmt.Errorf("已结账的扣款信息不允许修改", a)
|
||||
// }
|
||||
// dao.UpdateEntity(db, ordersSupplement)
|
||||
// } else {
|
||||
|
||||
// }
|
||||
func AddUpdateOrdersSupplement(ctx *jxcontext.Context, ordersSupplement *model.OrderSupplementFee) (num int64, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
id = ordersSupplement.ID
|
||||
)
|
||||
now := time.Now()
|
||||
ordersSupplement.SupplementTime = &now
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db)
|
||||
if r != nil {
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
}()
|
||||
if id > 0 {
|
||||
if ordersSupplement.Status == 1 {
|
||||
return 0, fmt.Errorf("已结账的扣款信息不允许修改!门店ID:[%v],订单号:[%v]", ordersSupplement.StoreID, ordersSupplement.VendorOrderID)
|
||||
}
|
||||
ordersSupplement.UpdatedAt = time.Now()
|
||||
ordersSupplement.LastOperator = ctx.GetUserName()
|
||||
if ordersSupplement.Status == -1 {
|
||||
ordersSupplement.DeletedAt = time.Now()
|
||||
} else {
|
||||
ordersSupplement.DeletedAt = utils.DefaultTimeValue
|
||||
}
|
||||
num, err = dao.UpdateEntity(db, ordersSupplement)
|
||||
} else {
|
||||
dao.WrapAddIDCULDEntity(ordersSupplement, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, ordersSupplement)
|
||||
}
|
||||
dao.Commit(db)
|
||||
return num, err
|
||||
}
|
||||
|
||||
@@ -347,8 +347,8 @@ type OrderSupplementFee struct {
|
||||
ModelIDCULD
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"`
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
Status int `json:"status"` //账单状态,若已结账则不允许再修改 ,暂时 0为未结账,1为已结账
|
||||
VendorID *string `orm:"column(vendor_id)" json:"vendorID"`
|
||||
Status int `json:"status"` //账单状态,若已结账则不允许再修改 ,暂时 0为未结账,1为已结账,-1为作废
|
||||
LinkID int `orm:"column(link_id)" json:"linkID"` //作为冲账标志关联某条扣款记录
|
||||
SupplementTime *time.Time `orm:"type(datetime);null" json:"supplementTime"`
|
||||
Type int `json:"type"` //扣款类型,1为差评订单补贴,2为优惠券
|
||||
|
||||
Reference in New Issue
Block a user