差评补款

This commit is contained in:
苏尹岚
2019-12-30 08:25:01 +08:00
parent b068d07c33
commit 6467def8b4
4 changed files with 59 additions and 19 deletions

View File

@@ -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
}

View File

@@ -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为优惠券

View File

@@ -929,12 +929,12 @@ func (c *OrderController) ComplaintRider() {
// @Title 查询门店订单扣款记录
// @Description 查询门店订单扣款记录
// @Param token header string true "认证token"
// @Param storeIDs query string true "门店ID列表"
// @Param vendorOrderID query string true "订单ID"
// @Param vendorIDs query string true "订单所属厂商ID列表"
// @Param storeIDs query string false "门店ID列表"
// @Param vendorOrderID query string false "订单ID"
// @Param vendorIDs query string false "订单所属厂商ID列表"
// @Param fromTime query string false "开始日期包含格式2006-01-02如果订单号为空此项必须要求"
// @Param toTime query string false "结束日期包含格式2006-01-02如果订单号为空此项必须要求"
// @Param status query int false "账单状态0是未结账1是已结账2是冲账"
// @Param status query int false "账单状态0是未结账1是已结账"
// @Param type query int false "扣款类型1为差评补贴2为优惠券"
// @Param offset query int false "结果起始序号以0开始缺省为0"
// @Param pageSize query int false "结果页大小缺省为50-1表示全部"

View File

@@ -711,6 +711,15 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
beego.ControllerComments{
Method: "AddUpdateOrdersSupplement",
Router: `/AddUpdateOrdersSupplement`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
beego.ControllerComments{
Method: "AdjustOrder",
@@ -927,6 +936,15 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
beego.ControllerComments{
Method: "GetOrdersSupplement",
Router: `/GetOrdersSupplement`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
beego.ControllerComments{
Method: "GetPrinterStatus",