diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index ab2da58d6..72105729a 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -746,3 +746,39 @@ func RefreshOrdersWithoutJxStoreID(ctx *jxcontext.Context, fromDate, toDate stri } return hint, err } + +func GetOrdersSupplement(ctx *jxcontext.Context, storIDs, vendorIDs []int, vendorOrderID, fromTime, toTime string, status, stype, offset, pageSize int) (pageInfo *model.PagedInfo, err error) { + var ( + db = dao.GetDB() + fromTimeP time.Time + toTimeP time.Time + ) + if fromTime != "" { + fromTimeP = utils.Str2Time(fromTime) + } + if toTime != "" { + toTimeP = utils.Str2Time(toTime) + } + result, totalCount, err := dao.GetOrdersSupplement(db, storIDs, vendorIDs, vendorOrderID, fromTimeP, toTimeP, status, stype, offset, pageSize) + pageInfo = &model.PagedInfo{ + Data: result, + TotalCount: totalCount, + } + 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 { + + } + return num, err +} diff --git a/business/model/order.go b/business/model/order.go index 0bc2c4d3f..3377721d0 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -345,7 +345,22 @@ type OrderPayRefund struct { type OrderSupplementFee struct { ModelIDCULD - VendorOrderID string `orm:"column(vendor_order_id);index;size(48)" json:"vendorOrderID"` + 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为已结账 + LinkID int `orm:"column(link_id)" json:"linkID"` //作为冲账标志关联某条扣款记录 + SupplementTime *time.Time `orm:"type(datetime);null" json:"supplementTime"` + Type int `json:"type"` //扣款类型,1为差评订单补贴,2为优惠券 + SupplementFee int `json:"supplementFee"` //扣款金额 + BillID string `orm:"column(bill_id);size(48)" json:"billID"` //账单ID + Comment string `orm:"size(255)" json:"comment"` +} + +func (v *OrderSupplementFee) TableIndex() [][]string { + return [][]string{ + []string{"StoreID", "VendorOrderID", "SupplementTime", "VendorID", "BillID"}, + } } // 判断是否是购买平台自有物流 diff --git a/controllers/jx_order.go b/controllers/jx_order.go index ebec2b769..6060b53ce 100644 --- a/controllers/jx_order.go +++ b/controllers/jx_order.go @@ -909,3 +909,45 @@ func (c *OrderController) ComplaintRider() { return retVal, "", err }) } + +// @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 fromTime query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" +// @Param toTime query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" +// @Param status query int false "账单状态,0是未结账,1是已结账,2是冲账" +// @Param type query int false "扣款类型,1为差评补贴,2为优惠券" +// @Param offset query int false "结果起始序号(以0开始,缺省为0)" +// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetOrdersSupplement [get] +func (c *OrderController) GetOrdersSupplement() { + var vendorIDList, storeIDList []int + c.callGetOrdersSupplement(func(params *tOrderGetOrdersSupplementParams) (retVal interface{}, errCode string, err error) { + if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil { + retVal, err = orderman.GetOrdersSupplement(params.Ctx, storeIDList, vendorIDList, params.VendorOrderID, params.FromTime, params.ToTime, params.Status, params.Type, params.Offset, params.PageSize) + } + return retVal, "", err + }) +} + +// @Title 新增修改扣款记录 +// @Description 新增修改扣款记录 +// @Param token header string true "认证token" +// @Param payload formData string true "json数据,格式为OrdersSupplement" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /AddUpdateOrdersSupplement [post] +func (c *OrderController) AddUpdateOrdersSupplement() { + c.callAddUpdateOrdersSupplement(func(params *tOrderAddUpdateOrdersSupplementParams) (retVal interface{}, errCode string, err error) { + ordersSupplement := &model.OrderSupplementFee{} + if err = utils.UnmarshalUseNumber([]byte(params.Payload), ordersSupplement); err == nil { + retVal, err = orderman.AddUpdateOrdersSupplement(params.Ctx, ordersSupplement) + } + return retVal, "", err + }) +} diff --git a/globals/beegodb/beegodb.go b/globals/beegodb/beegodb.go index 6ac7d068d..5ce864921 100644 --- a/globals/beegodb/beegodb.go +++ b/globals/beegodb/beegodb.go @@ -41,6 +41,7 @@ func Init() { orm.RegisterModel(&model.PriceReferSnapshot{}) orm.RegisterModel(&model.StorePriceScoreSnapshot{}) orm.RegisterModel(&model.StoreSkuNamePrice{}) + orm.RegisterModel(&model.OrderSupplementFee{}) // orm.RegisterModel(&model.ActivityForSku{}) // orm.RegisterModel(&legacymodel.JxBadComments2{})