This commit is contained in:
苏尹岚
2021-02-25 15:12:08 +08:00
parent 8d3d64e381
commit 966a11f394
6 changed files with 157 additions and 5 deletions

View File

@@ -649,6 +649,7 @@ func (c *OrderManager) updateOrderOtherInfo(order *model.GoodsOrder, db *dao.Dao
order.EarningType = model.EarningTypeQuote
}
order.OrderPayPercentage = payPercentage
order.CreateDeliveryType = storeDetail.CreateDeliveryType
}
if err = c.updateOrderSkuOtherInfo(order, db, payPercentage, changePriceType); err == nil {
jxutils.RefreshOrderSkuRelated(order)

View File

@@ -155,6 +155,18 @@ func (s *DefScheduler) CreateWaybillOnProvidersEx(ctx *jxcontext.Context, vendor
if order.DeliveryType == model.OrderDeliveryTypeSelfTake {
return nil, fmt.Errorf("订单:%s是自提单", vendorOrderID)
}
//1表示为门店发单需要验证门店账户余额情况
if order.CreateDeliveryType == model.YES {
//暂时这么认为len courierVendorIDs 为1表示是老板或者运营从小程序上点的立即发单因为小程序上是点哪个发哪个
//京西后台则是点一下发3个len courierVendorIDs 是0
//如果是小程序上点哪个扣哪个平台的钱
//如果是后台,则选最高的那个扣
if len(courierVendorIDs) == 1 {
} else if len(courierVendorIDs) == 0 {
}
}
if !forceCreate {
err = s.isPossibleSwitch2SelfDelivery(order)
}

View File

@@ -0,0 +1,107 @@
package cms
import (
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner"
)
type StoreAcctManager struct {
}
var (
FixedStoreAcctManager *StoreAcctManager
)
func init() {
FixedStoreAcctManager = &StoreAcctManager{}
partner.InitStoreAcctManager(FixedStoreAcctManager)
}
func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int) (err error) {
storeAcctIncome := &model.StoreAcctIncome{
StoreID: storeID,
IncomePrice: price,
Type: acctType,
UserID: ctx.GetUserID(),
}
dao.WrapAddIDCULEntity(storeAcctIncome, ctx.GetUserName())
err = dao.CreateEntity(db, storeAcctIncome)
return err
}
func (s *StoreAcctManager) InsertStoreAcctExpend(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int, vendorOrderID string) (err error) {
storeAcctExpend := &model.StoreAcctExpend{
StoreID: storeID,
ExpendPrice: price,
Type: acctType,
UserID: ctx.GetUserID(),
VendorOrderID: vendorOrderID,
}
dao.WrapAddIDCULEntity(storeAcctExpend, ctx.GetUserName())
err = dao.CreateEntity(db, storeAcctExpend)
return err
}
func (s *StoreAcctManager) UpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price int, isIncome bool) (err error) {
var (
db = dao.GetDB()
)
storeAcct := &model.StoreAcct{
StoreID: storeID,
}
if isIncome {
storeAcct.AccountBalance += price
} else {
storeAcct.AccountBalance -= price
}
dao.Begin(db)
defer func() {
if r := recover(); r != nil || err != nil {
dao.Rollback(db)
if r != nil {
panic(r)
}
}
}()
if err = dao.GetEntity(db, storeAcct, "StoreID"); err != nil && dao.IsNoRowsError(err) {
//新增门店账单
dao.WrapAddIDCULEntity(storeAcct, ctx.GetUserName())
if err = dao.CreateEntity(db, storeAcct); err != nil {
dao.Rollback(db)
return err
}
} else {
if _, err = dao.UpdateEntity(db, storeAcct, "AccountBalance"); err != nil {
dao.Rollback(db)
return err
}
}
dao.Commit(db)
return err
}
func (s *StoreAcctManager) InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error) {
var (
db = dao.GetDB()
)
if err = s.InsertStoreAcctExpend(ctx, db, storeID, price, acctType, vendorOrderID); err == nil {
s.UpdateStoreAcctBalance(ctx, storeID, price, false)
}
return err
}
func (s *StoreAcctManager) InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int) (err error) {
var (
db = dao.GetDB()
)
if err = s.InsertStoreAcctIncome(ctx, db, storeID, price, acctType); err == nil {
s.UpdateStoreAcctBalance(ctx, storeID, price, true)
}
return err
}
func (s *StoreAcctManager) CheckStoreAcctExpendExist(storeID int, vendorOrderID string) (result bool, err error) {
return false, err
}

View File

@@ -27,6 +27,7 @@ type StoreDetail struct {
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
PricePercentagePackStr string `orm:"size(4096)" json:"-"` //
PricePercentagePackObj model.PricePercentagePack `orm:"-" json:"-"`
CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` //默认0系统发单1为门店发单
FreightDeductionPackStr string `orm:"size(4096)" json:"-"` //
FreightDeductionPackObj *model.FreightDeductionPack `orm:"-" json:"-"`
@@ -110,7 +111,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID, vendorOrgCo
SELECT t1.*,
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee_deduction_sill, t2.delivery_fee_deduction_fee, t2.sync_status, t2.vendor_org_code,
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.vendor_store_name, t2.is_order, t2.yb_app_id, t2.yb_app_key, t2.yb_store_prefix,
t2.jds_street_code, t2.jds_street_name, t2.is_supply_goods, t2.vendor_pay_percentage, t2.mtwm_token, t2.ebai_supplier_id,
t2.jds_street_code, t2.jds_street_name, t2.is_supply_goods, t2.vendor_pay_percentage, t2.mtwm_token, t2.ebai_supplier_id, t2.create_delivery_type,
t3.value price_percentage_pack_str,
t4.value freight_deduction_pack_str,
province.name province_name,

View File

@@ -823,10 +823,11 @@ func (v *StoreAcctIncome) TableIndex() [][]string {
type StoreAcctExpend struct {
ModelIDCUL
StoreID int `orm:"column(store_id)" json:"storeID"` //门店ID
UserID string `orm:"column(user_id)" json:"userID"` //用户ID (谁消费的)
Type int `json:"type"` //支出类型
ExpendPrice int `json:"expendPrice"` //支出金额
StoreID int `orm:"column(store_id)" json:"storeID"` //门店ID
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"`
UserID string `orm:"column(user_id)" json:"userID"` //用户ID (谁消费的)
Type int `json:"type"` //支出类型
ExpendPrice int `json:"expendPrice"` //支出金额
}
func (v *StoreAcctExpend) TableIndex() [][]string {

View File

@@ -0,0 +1,30 @@
package partner
import (
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model/dao"
)
const (
StoreAcctType1 = 1 //主动充值
)
var (
CurStoreAcctManager IStoreAcctManager
)
func InitStoreAcctManager(curStoreManager IStoreAcctManager) {
CurStoreAcctManager = curStoreManager
}
type IStoreAcctManager interface {
//增加一条收入流水
InsertStoreAcctIncome(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int) (err error)
//增加一条支出流水
InsertStoreAcctExpend(ctx *jxcontext.Context, db *dao.DaoDB, storeID, price, acctType int, vendorOrderID string) (err error)
//更新门店账户
UpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price int, isIncome bool) (err error)
InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int) (err error)
CheckStoreAcctExpendExist(storeID int, vendorOrderID string) (result bool, err error)
}