aa
This commit is contained in:
@@ -35,6 +35,7 @@ const (
|
|||||||
OrderTypeMatter = 1 //物料订单
|
OrderTypeMatter = 1 //物料订单
|
||||||
OrderTypeSupplyGoods = 2 //进货订单
|
OrderTypeSupplyGoods = 2 //进货订单
|
||||||
OrderTypeDefendPrice = 3 //守价订单
|
OrderTypeDefendPrice = 3 //守价订单
|
||||||
|
OrderTypeStoreAcct = 4 //门店账户订单
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -482,33 +483,6 @@ func (v *StoreCoupons) TableIndex() [][]string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type AcctOrder struct {
|
|
||||||
ModelIDCUL
|
|
||||||
|
|
||||||
VendorOrderID string `orm:"column(vendor_order_id)" json:"vendorOrderID"` //订单号
|
|
||||||
UserID string `orm:"column(user_id);size(48)" json:"userID"` //用户ID
|
|
||||||
StoreID int `orm:"column(store_id)" json:"storeID"` //门店ID
|
|
||||||
OrderType int `json:"orderType"` //订单类型
|
|
||||||
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
|
||||||
PayPrice int `json:"payPrice"` //支付金额
|
|
||||||
OriginalData string `orm:"type(text)" json:"-"`
|
|
||||||
Comment string `orm:"size(255)" json:"comment"` //备注
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *AcctOrder) TableUnique() [][]string {
|
|
||||||
return [][]string{
|
|
||||||
[]string{"VendorOrderID"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *AcctOrder) TableIndex() [][]string {
|
|
||||||
return [][]string{
|
|
||||||
[]string{"CreatedAt"},
|
|
||||||
[]string{"StoreID"},
|
|
||||||
[]string{"UserID"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断是否是购买平台自有物流
|
// 判断是否是购买平台自有物流
|
||||||
// 对于京东,饿百来说,就是其自有的物流,对于微商城来说,是达达
|
// 对于京东,饿百来说,就是其自有的物流,对于微商城来说,是达达
|
||||||
func IsWaybillPlatformOwn(bill *Waybill) bool {
|
func IsWaybillPlatformOwn(bill *Waybill) bool {
|
||||||
|
|||||||
@@ -344,12 +344,11 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
|
|||||||
return orderPay, err
|
return orderPay, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func Pay4User(ctx *jxcontext.Context, thingID, payType int, vendorPayType string) (orderPay *model.OrderPay, err error) {
|
func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType int, vendorPayType string) (orderPay *model.OrderPay, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
order *model.GoodsOrder
|
order *model.GoodsOrder
|
||||||
dicountCards []*model.DiscountCard
|
dicountCards []*model.DiscountCard
|
||||||
vendorOrderID string
|
|
||||||
)
|
)
|
||||||
switch payType {
|
switch payType {
|
||||||
case model.PayTypeTL_DiscountCard:
|
case model.PayTypeTL_DiscountCard:
|
||||||
@@ -2431,7 +2430,39 @@ func RefreshCouponsStatus(ctx *jxcontext.Context) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateStoreAcctOrder(ctx *jxcontext.Context, orderType, storeID, price int) (acctOrder *model.AcctOrder, err error) {
|
func CreateStoreAcctOrder(ctx *jxcontext.Context, orderType, storeID, price int) (vendorOrderID string, err error) {
|
||||||
|
var (
|
||||||
return acctOrder, err
|
db = dao.GetDB()
|
||||||
|
storeAcct = &model.StoreAcct{
|
||||||
|
StoreID: storeID,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if err = dao.GetEntity(db, storeAcct, "StoreID"); err != nil && dao.IsNoRowsError(err) {
|
||||||
|
//新增门店账单
|
||||||
|
dao.WrapAddIDCULEntity(storeAcct, ctx.GetUserName())
|
||||||
|
dao.CreateEntity(db, storeAcct)
|
||||||
|
}
|
||||||
|
|
||||||
|
order := &model.GoodsOrder{
|
||||||
|
VendorOrderID: utils.Int64ToStr(jxutils.GenOrderNo()),
|
||||||
|
UserID: ctx.GetUserID(),
|
||||||
|
StoreID: storeID,
|
||||||
|
OrderType: orderType,
|
||||||
|
Status: model.OrderStatusWait4Pay,
|
||||||
|
ActualPayPrice: int64(price),
|
||||||
|
OrderCreatedAt: time.Now(),
|
||||||
|
VendorID: model.VendorIDJX,
|
||||||
|
}
|
||||||
|
dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err = dao.CreateEntity(db, order); err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
}
|
||||||
|
dao.Commit(db)
|
||||||
|
return order.VendorOrderID, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func (c *JxOrderController) Pay4Order() {
|
|||||||
// @router /Pay4User [post]
|
// @router /Pay4User [post]
|
||||||
func (c *JxOrderController) Pay4User() {
|
func (c *JxOrderController) Pay4User() {
|
||||||
c.callPay4User(func(params *tJxorderPay4UserParams) (retVal interface{}, errCode string, err error) {
|
c.callPay4User(func(params *tJxorderPay4UserParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = localjx.Pay4User(params.Ctx, params.ThingID, params.PayType, params.VendorPayType)
|
retVal, err = localjx.Pay4User(params.Ctx, params.ThingID, params.VendorOrderID, params.PayType, params.VendorPayType)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -372,7 +372,7 @@ func (c *JxOrderController) ReceiveCoupons() {
|
|||||||
// @Title 创建门店账户订单
|
// @Title 创建门店账户订单
|
||||||
// @Description 创建门店账户订单
|
// @Description 创建门店账户订单
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param orderType formData int true "订单类型,1为账户充值"
|
// @Param orderType formData int true "订单类型,4为门店账户订单"
|
||||||
// @Param storeID formData int true "门店ID"
|
// @Param storeID formData int true "门店ID"
|
||||||
// @Param price formData int true "支付金额"
|
// @Param price formData int true "支付金额"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
@@ -380,7 +380,7 @@ func (c *JxOrderController) ReceiveCoupons() {
|
|||||||
// @router /CreateStoreAcctOrder [post]
|
// @router /CreateStoreAcctOrder [post]
|
||||||
func (c *JxOrderController) CreateStoreAcctOrder() {
|
func (c *JxOrderController) CreateStoreAcctOrder() {
|
||||||
c.callCreateStoreAcctOrder(func(params *tJxorderCreateStoreAcctOrderParams) (retVal interface{}, errCode string, err error) {
|
c.callCreateStoreAcctOrder(func(params *tJxorderCreateStoreAcctOrderParams) (retVal interface{}, errCode string, err error) {
|
||||||
localjx.CreateStoreAcctOrder(params.Ctx, params.OrderType, params.StoreID, params.Price)
|
retVal, err = localjx.CreateStoreAcctOrder(params.Ctx, params.OrderType, params.StoreID, params.Price)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ func Init() {
|
|||||||
orm.RegisterModel(&model.StoreAcct{})
|
orm.RegisterModel(&model.StoreAcct{})
|
||||||
orm.RegisterModel(&model.StoreAcctExpend{})
|
orm.RegisterModel(&model.StoreAcctExpend{})
|
||||||
orm.RegisterModel(&model.StoreAcctIncome{})
|
orm.RegisterModel(&model.StoreAcctIncome{})
|
||||||
orm.RegisterModel(&model.AcctOrder{})
|
|
||||||
|
|
||||||
// create table
|
// create table
|
||||||
orm.RunSyncdb("default", false, true)
|
orm.RunSyncdb("default", false, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user