From 6467def8b48576ce11bb533788601b1a66ab1221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 30 Dec 2019 08:25:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=AE=E8=AF=84=E8=A1=A5=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 48 +++++++++++++++++++-------- business/model/order.go | 4 +-- controllers/jx_order.go | 8 ++--- routers/commentsRouter_controllers.go | 18 ++++++++++ 4 files changed, 59 insertions(+), 19 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 57233d17f..0aecd9ba0 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -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 } diff --git a/business/model/order.go b/business/model/order.go index a6759e673..ad64422f4 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -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为优惠券 diff --git a/controllers/jx_order.go b/controllers/jx_order.go index fcc99020b..ee9ae829a 100644 --- a/controllers/jx_order.go +++ b/controllers/jx_order.go @@ -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表示全部)" diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 5035e0c11..02877e5f9 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -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",