@@ -102,7 +102,7 @@ func StoreWithdrawAudit(c *gin.Context) { | |||
return | |||
} | |||
if req["state"] == "3" { | |||
bools := svc.MoneyCheck(c, sess, data.Uid, 0, 3, utils.StrToFloat64(data.Amount), "提现审核拒绝退回", utils.StrToInt64(utils.OrderUUID(data.Uid))) | |||
bools := svc.MoneyCheck(c, sess, data.Uid, data.ParentUid, data.StoreType, 0, 3, utils.StrToFloat64(data.Amount), "提现审核拒绝退回", utils.StrToInt64(utils.OrderUUID(data.Uid))) | |||
if bools == false { | |||
sess.Rollback() | |||
e.OutErr(c, 400, e.NewErr(400, "审核失败")) | |||
@@ -115,6 +115,9 @@ func GetStoreOrderList(eg *xorm.Engine, req md.StoreOrder, parent_uid int) (*[]m | |||
if req.StoreUid != "" { | |||
sess.And("store_uid=?", req.StoreUid) | |||
} | |||
if req.StoreType != "" { | |||
sess.And("store_type=?", req.StoreType) | |||
} | |||
if parent_uid > 0 { | |||
sess.And("parent_uid=?", parent_uid) | |||
} | |||
@@ -6,17 +6,17 @@ import ( | |||
"xorm.io/xorm" | |||
) | |||
func GetStoreAmount(sess *xorm.Session, storeId int, agentUid int) *model.CommunityTeamStoreAmount { | |||
func GetStoreAmount(sess *xorm.Session, storeId int, agentUid, storeType int) *model.CommunityTeamStoreAmount { | |||
var data model.CommunityTeamStoreAmount | |||
get, err := sess.Where("uid=? and parent_uid=?", storeId, agentUid).Get(&data) | |||
get, err := sess.Where("uid=? and parent_uid=? and store_type=?", storeId, agentUid, storeType).Get(&data) | |||
if get == false || err != nil { | |||
return nil | |||
} | |||
return &data | |||
} | |||
func GetStoreAmountEg(eg *xorm.Engine, storeId int, agentUid int) *model.CommunityTeamStoreAmount { | |||
func GetStoreAmountEg(eg *xorm.Engine, storeId int, agentUid, storeType int) *model.CommunityTeamStoreAmount { | |||
var data model.CommunityTeamStoreAmount | |||
get, err := eg.Where("uid=? and parent_uid=?", storeId, agentUid).Get(&data) | |||
get, err := eg.Where("uid=? and parent_uid=? and store_type=?", storeId, agentUid, storeType).Get(&data) | |||
if get == false || err != nil { | |||
return nil | |||
} | |||
@@ -31,6 +31,9 @@ func GetStoreAmountFlowList(eg *xorm.Engine, arg map[string]string) (*[]model.Co | |||
if arg["parent_uid"] != "" { | |||
sess.And("parent_uid=?", arg["parent_uid"]) | |||
} | |||
if arg["store_type"] != "" { | |||
sess.And("store_type=?", arg["store_type"]) | |||
} | |||
if arg["title"] != "" { | |||
sess.And("title like ?", "%"+arg["title"]+"%") | |||
} | |||
@@ -29,6 +29,9 @@ func CommWhere(eg *xorm.Engine, arg map[string]string) *xorm.Session { | |||
if arg["parent_uid"] != "" { | |||
sess.And("parent_uid=?", arg["parent_uid"]) | |||
} | |||
if arg["store_type"] != "" { | |||
sess.And("store_type=?", arg["store_type"]) | |||
} | |||
if arg["state"] != "" { | |||
sess.And("state=?", arg["state"]) | |||
} | |||
@@ -5,38 +5,39 @@ import ( | |||
) | |||
type CommunityTeamOrder struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"default 0 INT(11)"` | |||
StoreType int `json:"store_type" xorm:"default 0 comment('0官方自营店 1加盟店 2连锁店') INT(11)"` | |||
StoreUid int `json:"store_uid" xorm:"default 0 comment('门店用户id') INT(11)"` | |||
ParentUid int `json:"parent_uid" xorm:"default 0 comment('上级代理') INT(11)"` | |||
Num int `json:"num" xorm:"default 0 comment('') INT(11)"` | |||
CouponId int `json:"coupon_id" xorm:"default 0 comment('') INT(11)"` | |||
Address string `json:"address" xorm:"comment('详细地址') VARCHAR(255)"` | |||
Commission string `json:"commission" xorm:"default 0.00 comment('分佣(元)') DECIMAL(20,2)"` | |||
AgentCommission string `json:"agent_commission" xorm:"default 0.00 comment('分佣(元)') DECIMAL(20,2)"` | |||
CreateAt time.Time `json:"create_at" xorm:"DATETIME"` | |||
UpdateAt time.Time `json:"update_at" xorm:"DATETIME"` | |||
CancelAt time.Time `json:"cancel_at" xorm:"DATETIME"` | |||
BuyPhone string `json:"buy_phone" xorm:"VARCHAR(255)"` | |||
Phone string `json:"phone" xorm:"VARCHAR(255)"` | |||
BuyName string `json:"buy_name" xorm:"VARCHAR(255)"` | |||
State int `json:"state" xorm:"default 0 comment('0待付款 1已支付 2已提货') INT(11)"` | |||
PayAt time.Time `json:"pay_at" xorm:"comment('付款时间') DATETIME"` | |||
ConfirmAt time.Time `json:"confirm_at" xorm:"comment('提货时间') DATETIME"` | |||
Oid int64 `json:"oid" xorm:"default 0 comment('主单号') BIGINT(20)"` | |||
Code string `json:"code" xorm:"comment('提货码') VARCHAR(255)"` | |||
Type int `json:"type" xorm:"default 0 comment('0自提 1外卖') INT(1)"` | |||
PayMethod int `json:"pay_method" xorm:"default 0 comment('1余额 2支付宝 3微信') INT(11)"` | |||
PayId string `json:"pay_id" xorm:"comment('第三方的支付id') VARCHAR(255)"` | |||
Amount string `json:"amount" xorm:"default 0.00 comment('总金额') DECIMAL(20,2)"` | |||
Memo string `json:"memo" xorm:"comment('备注') VARCHAR(255)"` | |||
TakeTime time.Time `json:"take_time" xorm:"comment('预计提货时间') DATETIME"` | |||
MealNum int `json:"meal_num" xorm:"default 0 comment('餐具数量') INT(11)"` | |||
Coupon string `json:"coupon" xorm:"default 0.00 DECIMAL(10,2)"` | |||
Timer string `json:"timer" xorm:"comment('预计提货时间') VARCHAR(255)"` | |||
IsNow int `json:"is_now" xorm:"default 0 comment('是否立即提货') INT(1)"` | |||
StoreSettleAt int `json:"store_settle_at" xorm:"default 0 comment('') INT(11)"` | |||
SettleAt int `json:"settle_at" xorm:"default 0 comment('') INT(11)"` | |||
CommissionAt int `json:"commission_at" xorm:"default 0 comment('') INT(11)"` | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"default 0 INT(11)"` | |||
StoreType int `json:"store_type" xorm:"default 0 comment('0官方自营店 1加盟店 2连锁店') INT(11)"` | |||
StoreUid int `json:"store_uid" xorm:"default 0 comment('门店用户id') INT(11)"` | |||
ParentUid int `json:"parent_uid" xorm:"default 0 comment('上级代理') INT(11)"` | |||
Num int `json:"num" xorm:"default 0 comment('') INT(11)"` | |||
CouponId int `json:"coupon_id" xorm:"default 0 comment('') INT(11)"` | |||
Address string `json:"address" xorm:"comment('详细地址') VARCHAR(255)"` | |||
Commission string `json:"commission" xorm:"default 0.00 comment('分佣(元)') DECIMAL(20,2)"` | |||
AgentCommission string `json:"agent_commission" xorm:"default 0.00 comment('分佣(元)') DECIMAL(20,2)"` | |||
PlatformCommission string `json:"platform_commission" xorm:"default 0.00 comment('分佣(元)') DECIMAL(20,2)"` | |||
CreateAt time.Time `json:"create_at" xorm:"DATETIME"` | |||
UpdateAt time.Time `json:"update_at" xorm:"DATETIME"` | |||
CancelAt time.Time `json:"cancel_at" xorm:"DATETIME"` | |||
BuyPhone string `json:"buy_phone" xorm:"VARCHAR(255)"` | |||
Phone string `json:"phone" xorm:"VARCHAR(255)"` | |||
BuyName string `json:"buy_name" xorm:"VARCHAR(255)"` | |||
State int `json:"state" xorm:"default 0 comment('0待付款 1已支付 2已提货') INT(11)"` | |||
PayAt time.Time `json:"pay_at" xorm:"comment('付款时间') DATETIME"` | |||
ConfirmAt time.Time `json:"confirm_at" xorm:"comment('提货时间') DATETIME"` | |||
Oid int64 `json:"oid" xorm:"default 0 comment('主单号') BIGINT(20)"` | |||
Code string `json:"code" xorm:"comment('提货码') VARCHAR(255)"` | |||
Type int `json:"type" xorm:"default 0 comment('0自提 1外卖') INT(1)"` | |||
PayMethod int `json:"pay_method" xorm:"default 0 comment('1余额 2支付宝 3微信') INT(11)"` | |||
PayId string `json:"pay_id" xorm:"comment('第三方的支付id') VARCHAR(255)"` | |||
Amount string `json:"amount" xorm:"default 0.00 comment('总金额') DECIMAL(20,2)"` | |||
Memo string `json:"memo" xorm:"comment('备注') VARCHAR(255)"` | |||
TakeTime time.Time `json:"take_time" xorm:"comment('预计提货时间') DATETIME"` | |||
MealNum int `json:"meal_num" xorm:"default 0 comment('餐具数量') INT(11)"` | |||
Coupon string `json:"coupon" xorm:"default 0.00 DECIMAL(10,2)"` | |||
Timer string `json:"timer" xorm:"comment('预计提货时间') VARCHAR(255)"` | |||
IsNow int `json:"is_now" xorm:"default 0 comment('是否立即提货') INT(1)"` | |||
StoreSettleAt int `json:"store_settle_at" xorm:"default 0 comment('') INT(11)"` | |||
SettleAt int `json:"settle_at" xorm:"default 0 comment('') INT(11)"` | |||
CommissionAt int `json:"commission_at" xorm:"default 0 comment('') INT(11)"` | |||
} |
@@ -5,27 +5,28 @@ import ( | |||
) | |||
type CommunityTeamStore struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"default 0 INT(11)"` | |||
StoreType int `json:"store_type" xorm:"default 0 comment('0官方自营店 1加盟店 2连锁店') INT(11)"` | |||
ParentUid int `json:"parent_uid" xorm:"default 0 comment('上级代理') INT(11)"` | |||
Lat string `json:"lat" xorm:"default 0.000000 comment('纬度') DECIMAL(30,6)"` | |||
Lng string `json:"lng" xorm:"default 0.000000 comment('经度') DECIMAL(30,6)"` | |||
Address string `json:"address" xorm:"comment('详细地址') VARCHAR(255)"` | |||
Commission string `json:"commission" xorm:"default 0.00 comment('分佣比例%') DECIMAL(20,2)"` | |||
AgentCommission string `json:"agent_commission" xorm:"default 0.00 comment('分佣比例%') DECIMAL(20,2)"` | |||
CreateAt time.Time `json:"create_at" xorm:"DATETIME"` | |||
UpdateAt time.Time `json:"update_at" xorm:"DATETIME"` | |||
State int `json:"state" xorm:"default 0 comment('0非店长 1店长') INT(1)"` | |||
WorkState int `json:"work_state" xorm:"default 0 comment('0营业中 1休息中') INT(1)"` | |||
Name string `json:"name" xorm:"VARCHAR(255)"` | |||
Province string `json:"province" xorm:"comment('省级的名称') VARCHAR(255)"` | |||
City string `json:"city" xorm:"comment('市级的名称') VARCHAR(255)"` | |||
District string `json:"district" xorm:"comment('县,区名称') VARCHAR(255)"` | |||
Timer string `json:"timer" xorm:"comment('') VARCHAR(255)"` | |||
Phone string `json:"phone" xorm:"comment('') VARCHAR(255)"` | |||
Logo string `json:"logo" xorm:"comment('') VARCHAR(255)"` | |||
ProvinceId int `json:"province_id" xorm:"comment('省级的名称') INT(11)"` | |||
CityId int `json:"city_id" xorm:"comment('市级的名称') INT(11)"` | |||
DistrictId int `json:"district_id" xorm:"comment('县,区名称') INT(11)"` | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"default 0 INT(11)"` | |||
StoreType int `json:"store_type" xorm:"default 0 comment('0官方自营店 1加盟店 2连锁店') INT(11)"` | |||
ParentUid int `json:"parent_uid" xorm:"default 0 comment('上级代理') INT(11)"` | |||
Lat string `json:"lat" xorm:"default 0.000000 comment('纬度') DECIMAL(30,6)"` | |||
Lng string `json:"lng" xorm:"default 0.000000 comment('经度') DECIMAL(30,6)"` | |||
Address string `json:"address" xorm:"comment('详细地址') VARCHAR(255)"` | |||
Commission string `json:"commission" xorm:"default 0.00 comment('分佣比例%') DECIMAL(20,2)"` | |||
AgentCommission string `json:"agent_commission" xorm:"default 0.00 comment('分佣比例%') DECIMAL(20,2)"` | |||
PlatformCommission string `json:"platform_commission" xorm:"default 0.00 comment('分佣比例%') DECIMAL(20,2)"` | |||
CreateAt time.Time `json:"create_at" xorm:"DATETIME"` | |||
UpdateAt time.Time `json:"update_at" xorm:"DATETIME"` | |||
State int `json:"state" xorm:"default 0 comment('0非店长 1店长') INT(1)"` | |||
WorkState int `json:"work_state" xorm:"default 0 comment('0营业中 1休息中') INT(1)"` | |||
Name string `json:"name" xorm:"VARCHAR(255)"` | |||
Province string `json:"province" xorm:"comment('省级的名称') VARCHAR(255)"` | |||
City string `json:"city" xorm:"comment('市级的名称') VARCHAR(255)"` | |||
District string `json:"district" xorm:"comment('县,区名称') VARCHAR(255)"` | |||
Timer string `json:"timer" xorm:"comment('') VARCHAR(255)"` | |||
Phone string `json:"phone" xorm:"comment('') VARCHAR(255)"` | |||
Logo string `json:"logo" xorm:"comment('') VARCHAR(255)"` | |||
ProvinceId int `json:"province_id" xorm:"comment('省级的名称') INT(11)"` | |||
CityId int `json:"city_id" xorm:"comment('市级的名称') INT(11)"` | |||
DistrictId int `json:"district_id" xorm:"comment('县,区名称') INT(11)"` | |||
} |
@@ -19,5 +19,6 @@ type CommunityTeamStoreWithdrawApply struct { | |||
State int `json:"state" xorm:"not null default 0 comment('0申请中,1通过,2完成,3失败') TINYINT(1)"` | |||
Platform string `json:"platform" xorm:"VARCHAR(255)"` | |||
ParentUid int `json:"parent_uid" xorm:"default 0 INT(11)"` | |||
StoreType int `json:"store_type" xorm:"default 0 INT(11)"` | |||
Oid int64 `json:"oid" xorm:"BIGINT(20)"` | |||
} |
@@ -27,6 +27,7 @@ type StoreOrder struct { | |||
EndTime string `json:"end_time"` | |||
Oid string `json:"oid"` | |||
StoreUid string `json:"store_uid"` | |||
StoreType string `json:"store_type"` | |||
StoreName string `json:"store_name"` | |||
ConfirmStartTime string `json:"confirm_start_time"` | |||
ConfirmEndTime string `json:"confirm_end_time"` | |||
@@ -123,17 +123,19 @@ func UserStoreOrder(c *gin.Context) { | |||
stateList := []string{"待付款", "已支付", "已提货", "已取消"} | |||
for _, v := range *data { | |||
tmp := map[string]string{ | |||
"oid": utils.Int64ToStr(v.Oid), | |||
"uid": utils.IntToStr(v.Uid), | |||
"phone": "", | |||
"nickname": "", | |||
"store_name": "", | |||
"state_str": stateList[v.State], | |||
"amount": v.Amount, | |||
"agent_commission": v.AgentCommission, | |||
"state": utils.IntToStr(v.State), | |||
"create_at": v.CreateAt.Format("2006-01-02 15:04:05"), | |||
"confirm_at": utils.Int64ToStr(v.Oid), | |||
"oid": utils.Int64ToStr(v.Oid), | |||
"uid": utils.IntToStr(v.Uid), | |||
"phone": "", | |||
"nickname": "", | |||
"store_name": "", | |||
"state_str": stateList[v.State], | |||
"amount": v.Amount, | |||
"agent_commission": v.AgentCommission, | |||
"platform_commission": v.PlatformCommission, | |||
"commission": v.Commission, | |||
"state": utils.IntToStr(v.State), | |||
"create_at": v.CreateAt.Format("2006-01-02 15:04:05"), | |||
"confirm_at": utils.Int64ToStr(v.Oid), | |||
} | |||
if v.ConfirmAt.IsZero() == false { | |||
tmp["confirm_at"] = v.ConfirmAt.Format("2006-01-02 15:04:05") | |||
@@ -52,8 +52,14 @@ func StoreOrderConfirm(c *gin.Context) { | |||
return | |||
} | |||
//给商家余额 | |||
money := utils.StrToFloat64(order.Amount) - utils.StrToFloat64(order.AgentCommission) | |||
bools := svc.MoneyCheck(c, sess, order.StoreUid, 0, 1, money, "订单核销", order.Oid) | |||
money := utils.StrToFloat64(order.Commission) | |||
if order.ParentUid > 0 { | |||
money = utils.StrToFloat64(order.Amount) - utils.StrToFloat64(order.AgentCommission) | |||
} | |||
if order.StoreType == 1 { | |||
money = utils.StrToFloat64(order.Amount) - utils.StrToFloat64(order.PlatformCommission) | |||
} | |||
bools := svc.MoneyCheck(c, sess, order.StoreUid, order.ParentUid, order.StoreType, 0, 1, money, "订单核销", order.Oid) | |||
if bools == false { | |||
sess.Rollback() | |||
e.OutErr(c, 400, e.NewErr(400, "订单确认失败")) | |||
@@ -21,11 +21,19 @@ func StoreAmountBase(c *gin.Context) { | |||
if user.Profile.AccAlipay != "" { | |||
res["is_bind"] = "1" | |||
} | |||
amount, _ := svc.MasterDb(c).Where("store_uid=? and parent_uid>0 and state=1", user.Info.Uid).Sum(&model.CommunityTeamOrder{}, "amount-agent_commission") | |||
res["wait_amount"] = utils.Float64ToStr(amount) | |||
store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid)) | |||
if store != nil { | |||
amountData := db.GetStoreAmountEg(svc.MasterDb(c), user.Info.Uid, store.ParentUid) | |||
str := "commission" | |||
if store.ParentUid > 0 { | |||
str = "amount-agent_commission" | |||
} | |||
if store.StoreType == 1 { | |||
str = "amount-platform_commission" | |||
} | |||
amount, _ := svc.MasterDb(c).Where("store_uid=? and parent_uid=? and store_type=? and state=1", user.Info.Uid, store.ParentUid, store.StoreType).Sum(&model.CommunityTeamOrder{}, str) | |||
res["wait_amount"] = utils.Float64ToStr(amount) | |||
amountData := db.GetStoreAmountEg(svc.MasterDb(c), user.Info.Uid, store.ParentUid, store.StoreType) | |||
if amountData != nil { | |||
res["amount"] = amountData.Amount | |||
} | |||
@@ -41,6 +49,11 @@ func StoreAmountFlow(c *gin.Context) { | |||
} | |||
user := svc.GetUser(c) | |||
req["store_uid"] = utils.IntToStr(user.Info.Uid) | |||
store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid)) | |||
if store != nil { | |||
req["parent_uid"] = utils.IntToStr(store.ParentUid) | |||
req["store_type"] = utils.IntToStr(store.StoreType) | |||
} | |||
withdraw, total := db.GetStoreAmountFlowList(svc.MasterDb(c), req) | |||
list := make([]map[string]string, 0) | |||
if withdraw != nil { | |||
@@ -23,6 +23,11 @@ func StoreWithdrawFlow(c *gin.Context) { | |||
} | |||
user := svc.GetUser(c) | |||
req["store_uid"] = utils.IntToStr(user.Info.Uid) | |||
store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid)) | |||
if store != nil { | |||
req["parent_uid"] = utils.IntToStr(store.ParentUid) | |||
req["store_type"] = utils.IntToStr(store.StoreType) | |||
} | |||
withdraw, total := db.GetStoreWithdraw(svc.MasterDb(c), req) | |||
list := make([]map[string]string, 0) | |||
if withdraw != nil { | |||
@@ -71,11 +76,7 @@ func StoreWithdrawDoing(c *gin.Context) { | |||
e.OutErr(c, 400, e.NewErr(400, "提现失败")) | |||
return | |||
} | |||
if store.ParentUid == 0 { | |||
e.OutErr(c, 400, e.NewErr(400, "提现失败")) | |||
return | |||
} | |||
bools := svc.MoneyCheck(c, sess, user.Info.Uid, 1, 2, utils.StrToFloat64(req["amount"]), "提现", oid) | |||
bools := svc.MoneyCheck(c, sess, user.Info.Uid, store.ParentUid, store.StoreType, 1, 2, utils.StrToFloat64(req["amount"]), "提现", oid) | |||
if bools == false { | |||
e.OutErr(c, 400, e.NewErr(400, "提现失败")) | |||
return | |||
@@ -83,6 +84,7 @@ func StoreWithdrawDoing(c *gin.Context) { | |||
var flow = &model.CommunityTeamStoreWithdrawApply{ | |||
Uid: user.Info.Uid, | |||
ParentUid: store.ParentUid, | |||
StoreType: store.StoreType, | |||
Amount: req["amount"], | |||
Type: 1, | |||
WithdrawAccount: user.Profile.AccAlipay, | |||
@@ -12,6 +12,12 @@ func Cate(c *gin.Context) { | |||
if storeId == "" { | |||
storeId = "0" | |||
} | |||
if utils.StrToInt(storeId) > 0 { | |||
storeData := db.GetStoreIdEg(MasterDb(c), storeId) | |||
if storeData.StoreType == 0 { | |||
storeId = "0" | |||
} | |||
} | |||
cate := db.GetCate(MasterDb(c), storeId) | |||
cateList := make([]map[string]string, 0) | |||
if cate != nil { | |||
@@ -17,8 +17,15 @@ func Goods(c *gin.Context) { | |||
storeId := c.GetHeader("store_id") | |||
arg["store_type"] = "0" | |||
if utils.StrToInt(storeId) > 0 { | |||
arg["store_id"] = storeId | |||
arg["store_type"] = "1" | |||
arg["uid"] = storeId | |||
storeData := db.GetStoreIdEg(MasterDb(c), storeId) | |||
if storeData.StoreType == 2 { | |||
storeData.StoreType = 1 | |||
} | |||
if storeData.StoreType == 0 { | |||
arg["uid"] = "0" | |||
} | |||
arg["store_type"] = utils.IntToStr(storeData.StoreType) | |||
} | |||
goods := db.GetGoods(MasterDb(c), arg) | |||
goodsList := make([]map[string]interface{}, 0) | |||
@@ -235,11 +235,14 @@ func CommCoupon(c *gin.Context, totalPrice string) map[string]interface{} { | |||
couponList := make([]md.CouponList, 0) | |||
storeId := c.GetHeader("store_id") | |||
if utils.StrToInt(storeId) > 0 { | |||
returnData := map[string]interface{}{ | |||
"total": "0", | |||
"coupon_list": couponList, | |||
storeData := db.GetStoreIdEg(MasterDb(c), storeId) | |||
if storeData != nil && storeData.StoreType > 0 { | |||
returnData := map[string]interface{}{ | |||
"total": "0", | |||
"coupon_list": couponList, | |||
} | |||
return returnData | |||
} | |||
return returnData | |||
} | |||
var err error | |||
engine := MasterDb(c) | |||
@@ -444,28 +447,26 @@ func OrderConfirm(c *gin.Context) { | |||
order.State = 2 | |||
order.UpdateAt = time.Now() | |||
order.ConfirmAt = time.Now() | |||
order.StoreSettleAt = int(time.Now().Unix()) | |||
update, err := sess.Where("id=?", order.Id).Cols("state,confirm_at,update_at").Update(order) | |||
if update == 0 || err != nil { | |||
sess.Rollback() | |||
e.OutErr(c, 400, e.NewErr(400, "订单确认失败")) | |||
return | |||
} | |||
//给商家余额 | |||
store := db.GetStoreId(sess, utils.IntToStr(order.StoreUid)) | |||
if store == nil { | |||
money := utils.StrToFloat64(order.Commission) | |||
if order.ParentUid > 0 { | |||
money = utils.StrToFloat64(order.Amount) - utils.StrToFloat64(order.AgentCommission) | |||
} | |||
if order.StoreType == 1 { | |||
money = utils.StrToFloat64(order.Amount) - utils.StrToFloat64(order.PlatformCommission) | |||
} | |||
bools := MoneyCheck(c, sess, order.StoreUid, order.ParentUid, order.StoreType, 0, 1, money, "订单核销", order.Oid) | |||
if bools == false { | |||
sess.Rollback() | |||
e.OutErr(c, 400, e.NewErr(400, "订单确认失败")) | |||
return | |||
} | |||
if store.ParentUid > 0 { | |||
money := utils.StrToFloat64(order.Amount) - utils.StrToFloat64(order.AgentCommission) | |||
bools := MoneyCheck(c, sess, order.StoreUid, 0, 1, money, "订单核销", order.Oid) | |||
if bools == false { | |||
sess.Rollback() | |||
e.OutErr(c, 400, e.NewErr(400, "订单确认失败")) | |||
return | |||
} | |||
} | |||
sess.Commit() | |||
e.OutSuc(c, "success", nil) | |||
return | |||
@@ -528,9 +529,15 @@ func OrderCreate(c *gin.Context) { | |||
} | |||
if store.ParentUid > 0 { //代理下门店 | |||
order.StoreType = 2 | |||
order.Commission = "0" | |||
order.ParentUid = store.ParentUid | |||
order.AgentCommission = utils.Float64ToStr(utils.FloatFormat(utils.AnyToFloat64(totalPrice)*(utils.AnyToFloat64(store.AgentCommission)/100), 2)) | |||
} | |||
if store.StoreType == 1 { | |||
order.StoreType = 1 | |||
order.Commission = "0" | |||
order.PlatformCommission = utils.Float64ToStr(utils.FloatFormat(utils.AnyToFloat64(totalPrice)*(utils.AnyToFloat64(store.PlatformCommission)/100), 2)) | |||
} | |||
if utils.StrToFloat64(coupon) > 0 { | |||
order.CouponId = utils.StrToInt(arg.CouponId) | |||
} | |||
@@ -123,7 +123,11 @@ func StoreLike(c *gin.Context) { | |||
storeId := c.GetHeader("store_id") | |||
if utils.StrToInt(storeId) > 0 { | |||
arg["store_id"] = storeId | |||
arg["store_type"] = "1" | |||
storeData := db.GetStoreIdEg(MasterDb(c), storeId) | |||
if storeData.StoreType == 0 { | |||
arg["store_id"] = "0" | |||
} | |||
arg["store_type"] = utils.IntToStr(storeData.StoreType) | |||
} | |||
user, _ := GetDefaultUser(c, c.GetHeader("Authorization")) | |||
store := db.GetStoreLike(MasterDb(c), arg) | |||
@@ -176,7 +180,11 @@ func Store(c *gin.Context) { | |||
storeId := c.GetHeader("store_id") | |||
if utils.StrToInt(storeId) > 0 { | |||
arg["store_id"] = storeId | |||
arg["store_type"] = "1" | |||
storeData := db.GetStoreIdEg(MasterDb(c), storeId) | |||
if storeData.StoreType == 0 { | |||
arg["store_id"] = "0" | |||
} | |||
arg["store_type"] = utils.IntToStr(storeData.StoreType) | |||
} | |||
user, _ := GetDefaultUser(c, c.GetHeader("Authorization")) | |||
store := db.GetStore(MasterDb(c), arg) | |||
@@ -278,40 +278,30 @@ func StoreOrderConfirm(c *gin.Context) { | |||
e.OutErr(c, 400, e.NewErr(400, "订单确认失败")) | |||
return | |||
} | |||
//给商家余额 | |||
store := db.GetStoreId(sess, utils.IntToStr(order.StoreUid)) | |||
if store == nil { | |||
money := utils.StrToFloat64(order.Commission) | |||
if order.ParentUid > 0 { | |||
money = utils.StrToFloat64(order.Amount) - utils.StrToFloat64(order.AgentCommission) | |||
} | |||
if order.StoreType == 1 { | |||
money = utils.StrToFloat64(order.Amount) - utils.StrToFloat64(order.PlatformCommission) | |||
} | |||
bools := MoneyCheck(c, sess, order.StoreUid, order.ParentUid, order.StoreType, 0, 1, money, "订单核销", order.Oid) | |||
if bools == false { | |||
sess.Rollback() | |||
e.OutErr(c, 400, e.NewErr(400, "订单确认失败")) | |||
return | |||
} | |||
if store.ParentUid > 0 { | |||
money := utils.StrToFloat64(order.Amount) - utils.StrToFloat64(order.AgentCommission) | |||
bools := MoneyCheck(c, sess, order.StoreUid, 0, 1, money, "订单核销", order.Oid) | |||
if bools == false { | |||
sess.Rollback() | |||
e.OutErr(c, 400, e.NewErr(400, "订单确认失败")) | |||
return | |||
} | |||
} | |||
sess.Commit() | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func MoneyCheck(c *gin.Context, sess *xorm.Session, storeId, types, ordType int, money float64, title string, oid int64) bool { | |||
store := db.GetStoreId(sess, utils.IntToStr(storeId)) | |||
if store == nil { | |||
return false | |||
} | |||
if store.ParentUid == 0 { | |||
return false | |||
} | |||
amountData := db.GetStoreAmount(sess, storeId, store.ParentUid) | |||
func MoneyCheck(c *gin.Context, sess *xorm.Session, storeId, ParentUid, StoreType, types, ordType int, money float64, title string, oid int64) bool { | |||
amountData := db.GetStoreAmount(sess, storeId, ParentUid, StoreType) | |||
if amountData == nil { | |||
amountData = &model.CommunityTeamStoreAmount{ | |||
Uid: storeId, | |||
ParentUid: store.ParentUid, | |||
StoreType: store.StoreType, | |||
ParentUid: ParentUid, | |||
StoreType: StoreType, | |||
} | |||
insert, err := sess.Insert(amountData) | |||
if insert == 0 || err != nil { | |||
@@ -333,8 +323,8 @@ func MoneyCheck(c *gin.Context, sess *xorm.Session, storeId, types, ordType int, | |||
} | |||
var flow = &model.CommunityTeamStoreAmountFlow{ | |||
Uid: storeId, | |||
StoreType: store.StoreType, | |||
ParentUid: store.ParentUid, | |||
StoreType: StoreType, | |||
ParentUid: ParentUid, | |||
Amount: utils.Float64ToStr(money), | |||
BeforeAmount: before, | |||
AfterAmount: amountData.Amount, | |||
@@ -108,7 +108,5 @@ func doTask(dbName, fnName string) func() { | |||
// 增加自动任务队列 | |||
func initTasks() { | |||
jobs[md.KEY_CFG_CRON_COMMUNITY_TEAM_ORDER_CANCEL] = taskOrderCancel // | |||
jobs[md.KEY_CFG_CRON_COMMUNITY_TEAM_ORDER_STORE_SETTLE] = taskOrderStoreSettle // | |||
jobs[md.KEY_CFG_CRON_COMMUNITY_TEAM_ORDER_CANCEL] = taskOrderCancel // | |||
} |
@@ -0,0 +1,58 @@ | |||
apiVersion: apps/v1 | |||
kind: Deployment | |||
metadata: | |||
labels: | |||
app: community-team-agent | |||
annotations: | |||
kubesphere.io/creator: dengbiao | |||
kubesphere.io/description: community-team-agent | |||
name: community-team-agent | |||
namespace: develop | |||
spec: | |||
replicas: 1 | |||
selector: | |||
matchLabels: | |||
app: community-team-agent | |||
template: | |||
metadata: | |||
labels: | |||
app: community-team-agent | |||
spec: | |||
volumes: | |||
# 用于时区校正 | |||
- name: host-time | |||
hostPath: | |||
path: /etc/localtime | |||
type: '' | |||
# pvc | |||
- name: community-team-agent-pvc # 在该部署中的名称,后面使用改名称挂载 | |||
persistentVolumeClaim: | |||
claimName: community-team-agent-pvc # pvc的名称 | |||
# Nginx配置 | |||
- name: community-team-agent-nginx | |||
configMap: | |||
name: community-team-agent-nginx # 外部configMap的名称 | |||
items: | |||
- key: nginx.conf | |||
path: default.conf | |||
containers: | |||
- image: nginx | |||
imagePullPolicy: IfNotPresent | |||
name: community-team-agent | |||
ports: | |||
- containerPort: 80 | |||
name: tcp-80 | |||
protocol: TCP | |||
resources: {} | |||
volumeMounts: | |||
- name: host-time | |||
mountPath: /etc/localtime | |||
readOnly: true | |||
- name: community-team-agent-nginx | |||
mountPath: /etc/nginx/conf.d/default.conf | |||
readOnly: true | |||
subPath: default.conf | |||
- name: community-team-agent-pvc | |||
mountPath: /usr/share/nginx/html | |||
dnsPolicy: ClusterFirst | |||
restartPolicy: Always |
@@ -0,0 +1,58 @@ | |||
apiVersion: apps/v1 | |||
kind: Deployment | |||
metadata: | |||
labels: | |||
app: community-team-agent | |||
annotations: | |||
kubesphere.io/creator: dengbiao | |||
kubesphere.io/description: community-team-agent | |||
name: community-team-agent | |||
namespace: zhios | |||
spec: | |||
replicas: 1 | |||
selector: | |||
matchLabels: | |||
app: community-team-agent | |||
template: | |||
metadata: | |||
labels: | |||
app: community-team-agent | |||
spec: | |||
volumes: | |||
# 用于时区校正 | |||
- name: host-time | |||
hostPath: | |||
path: /etc/localtime | |||
type: '' | |||
# pvc | |||
- name: community-team-agent-pvc # 在该部署中的名称,后面使用改名称挂载 | |||
persistentVolumeClaim: | |||
claimName: community-team-agent-pvc # pvc的名称 | |||
# Nginx配置 | |||
- name: community-team-agent-nginx | |||
configMap: | |||
name: community-team-agent-nginx # 外部configMap的名称 | |||
items: | |||
- key: nginx.conf | |||
path: default.conf | |||
containers: | |||
- image: nginx | |||
imagePullPolicy: IfNotPresent | |||
name: community-team-agent | |||
ports: | |||
- containerPort: 80 | |||
name: tcp-80 | |||
protocol: TCP | |||
resources: {} | |||
volumeMounts: | |||
- name: host-time | |||
mountPath: /etc/localtime | |||
readOnly: true | |||
- name: community-team-agent-nginx | |||
mountPath: /etc/nginx/conf.d/default.conf | |||
readOnly: true | |||
subPath: default.conf | |||
- name: community-team-agent-pvc | |||
mountPath: /usr/share/nginx/html | |||
dnsPolicy: ClusterFirst | |||
restartPolicy: Always |
@@ -0,0 +1,58 @@ | |||
apiVersion: apps/v1 | |||
kind: Deployment | |||
metadata: | |||
labels: | |||
app: community-team-merchant | |||
annotations: | |||
kubesphere.io/creator: dengbiao | |||
kubesphere.io/description: community-team-merchant | |||
name: community-team-merchant | |||
namespace: develop | |||
spec: | |||
replicas: 1 | |||
selector: | |||
matchLabels: | |||
app: community-team-merchant | |||
template: | |||
metadata: | |||
labels: | |||
app: community-team-merchant | |||
spec: | |||
volumes: | |||
# 用于时区校正 | |||
- name: host-time | |||
hostPath: | |||
path: /etc/localtime | |||
type: '' | |||
# pvc | |||
- name: community-team-merchant-pvc # 在该部署中的名称,后面使用改名称挂载 | |||
persistentVolumeClaim: | |||
claimName: community-team-merchant-pvc # pvc的名称 | |||
# Nginx配置 | |||
- name: community-team-merchant-nginx | |||
configMap: | |||
name: community-team-merchant-nginx # 外部configMap的名称 | |||
items: | |||
- key: nginx.conf | |||
path: default.conf | |||
containers: | |||
- image: nginx | |||
imagePullPolicy: IfNotPresent | |||
name: community-team-merchant | |||
ports: | |||
- containerPort: 80 | |||
name: tcp-80 | |||
protocol: TCP | |||
resources: {} | |||
volumeMounts: | |||
- name: host-time | |||
mountPath: /etc/localtime | |||
readOnly: true | |||
- name: community-team-merchant-nginx | |||
mountPath: /etc/nginx/conf.d/default.conf | |||
readOnly: true | |||
subPath: default.conf | |||
- name: community-team-merchant-pvc | |||
mountPath: /usr/share/nginx/html | |||
dnsPolicy: ClusterFirst | |||
restartPolicy: Always |
@@ -0,0 +1,58 @@ | |||
apiVersion: apps/v1 | |||
kind: Deployment | |||
metadata: | |||
labels: | |||
app: community-team-merchant | |||
annotations: | |||
kubesphere.io/creator: dengbiao | |||
kubesphere.io/description: community-team-merchant | |||
name: community-team-merchant | |||
namespace: zhios | |||
spec: | |||
replicas: 1 | |||
selector: | |||
matchLabels: | |||
app: community-team-merchant | |||
template: | |||
metadata: | |||
labels: | |||
app: community-team-merchant | |||
spec: | |||
volumes: | |||
# 用于时区校正 | |||
- name: host-time | |||
hostPath: | |||
path: /etc/localtime | |||
type: '' | |||
# pvc | |||
- name: community-team-merchant-pvc # 在该部署中的名称,后面使用改名称挂载 | |||
persistentVolumeClaim: | |||
claimName: community-team-merchant-pvc # pvc的名称 | |||
# Nginx配置 | |||
- name: community-team-merchant-nginx | |||
configMap: | |||
name: community-team-merchant-nginx # 外部configMap的名称 | |||
items: | |||
- key: nginx.conf | |||
path: default.conf | |||
containers: | |||
- image: nginx | |||
imagePullPolicy: IfNotPresent | |||
name: community-team-merchant | |||
ports: | |||
- containerPort: 80 | |||
name: tcp-80 | |||
protocol: TCP | |||
resources: {} | |||
volumeMounts: | |||
- name: host-time | |||
mountPath: /etc/localtime | |||
readOnly: true | |||
- name: community-team-merchant-nginx | |||
mountPath: /etc/nginx/conf.d/default.conf | |||
readOnly: true | |||
subPath: default.conf | |||
- name: community-team-merchant-pvc | |||
mountPath: /usr/share/nginx/html | |||
dnsPolicy: ClusterFirst | |||
restartPolicy: Always |
@@ -0,0 +1,17 @@ | |||
kind: Ingress | |||
apiVersion: extensions/v1beta1 | |||
metadata: | |||
name: community-team-merchant # ingress名称 | |||
namespace: develop | |||
annotations: | |||
kubesphere.io/creator: dengbiao | |||
spec: | |||
rules: | |||
- host: '*.m.fnuo123.com.cn' | |||
http: | |||
paths: | |||
- path: / | |||
pathType: Exact | |||
backend: | |||
serviceName: community-team-merchant # 流量转发到的服务 | |||
servicePort: 80 |
@@ -0,0 +1,20 @@ | |||
apiVersion: networking.k8s.io/v1 | |||
kind: Ingress | |||
metadata: | |||
annotations: | |||
cert-manager.io/cluster-issuer: letsencrypt-prod | |||
kubesphere.io/creator: dengbiao | |||
name: community-team-agent | |||
namespace: zhios | |||
spec: | |||
rules: | |||
- host: '*.p.zhiyingos.cn' | |||
http: | |||
paths: | |||
- backend: | |||
service: | |||
name: community-team-agent | |||
port: | |||
number: 80 | |||
path: / | |||
pathType: ImplementationSpecific |
@@ -0,0 +1,17 @@ | |||
kind: Ingress | |||
apiVersion: extensions/v1beta1 | |||
metadata: | |||
name: community-team-merchant # ingress名称 | |||
namespace: develop | |||
annotations: | |||
kubesphere.io/creator: dengbiao | |||
spec: | |||
rules: | |||
- host: '*.m.fnuo123.com.cn' | |||
http: | |||
paths: | |||
- path: / | |||
pathType: Exact | |||
backend: | |||
serviceName: community-team-merchant # 流量转发到的服务 | |||
servicePort: 80 |
@@ -0,0 +1,20 @@ | |||
apiVersion: networking.k8s.io/v1 | |||
kind: Ingress | |||
metadata: | |||
annotations: | |||
cert-manager.io/cluster-issuer: letsencrypt-prod | |||
kubesphere.io/creator: dengbiao | |||
name: community-team-merchant | |||
namespace: zhios | |||
spec: | |||
rules: | |||
- host: '*.m.zhiyingos.cn' | |||
http: | |||
paths: | |||
- backend: | |||
service: | |||
name: community-team-merchant | |||
port: | |||
number: 80 | |||
path: / | |||
pathType: ImplementationSpecific |