作者 陈志颖

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/partnermg into dev

... ... @@ -16,7 +16,7 @@ import (
//从其他系统接收订单数据
const (
BEST_SHOP_UNIONID string = "gh_18eb644002fb" //海鲜干货小程序原始id
BEST_SHOP_UNIONID string = "gh_18eb644002fb" //香米小程序原始id
)
type SyncOrderService struct {
... ... @@ -79,6 +79,7 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests
//
logs.Warning("订单数据已存在:order_code=%s", cmd.OrderCode)
} else {
//复制数据到order_base表
err = s.CreateOrderFromBestshop(cmd)
}
return err
... ... @@ -225,6 +226,8 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
}
for _, v := range companyData.Applets {
//BEST_SHOP_UNIONID string = "gh_18eb644002fb" //香米小程序原始id
//接收香米小程序的订单数据
if len(v.Id) > 0 {
canCopyOrder = true
}
... ... @@ -237,7 +240,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
orderbase domain.OrderBase
ordergoods []domain.OrderGood
)
//TODO 添加orderBase
//添加orderBase
orderBestshop.CopyToOrderBase(&orderbase)
orderbase.CompanyId = companyData.Id
for i := range orderBestshop.Goods {
... ... @@ -245,13 +248,15 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
orderBestshop.Goods[i].CopyToOrderGood(&good)
good.CompanyId = partnerData.CompanyId
good.Compute()
//初始接收的订单按照待支付状态处理
good.CurrentBonusStatus.WartPayPartnerBonus(&good)
ordergoods = append(ordergoods, good)
}
orderbase.Goods = ordergoods
orderbase.PartnerId = partnerData.Partner.Id
orderbase.CompanyId = partnerData.CompanyId
orderbase.PartnerCategory = domain.PartnerCategory{Id: 1, Name: "事业合伙人"} // 默认设定为事业合伙人订单
// 默认设定为事业合伙人订单
orderbase.PartnerCategory = domain.PartnerCategory{Id: 1, Name: "事业合伙人"}
orderbase.Compute()
err = orderBaseRepository.Save(&orderbase)
if err != nil {
... ...
... ... @@ -6,8 +6,9 @@ import (
)
type SyncCallbackCommand struct {
//position:职位,department:部门,employee:员工,company:公司
//模块:position:职位,department:部门,employee:员工,company:公司
Module string `json:"module"`
//动作:
//add:添加,edit:编辑,delete删除,batchDelete:批量删除,
//setCompanyCharge:更改公司主管,batchForbid:批量禁用用户,
//batchRemove:批量更改用户部门,changeAdmin换管理员
... ...
... ... @@ -198,16 +198,25 @@ func (order *OrderBase) Compute() error {
planPartnerBonus := decimal.NewFromFloat(0)
planOrderAmount := decimal.NewFromFloat(0)
var (
planOrderCount int = 0
useOrderCount int = 0
//预计的货品总数,不包含调整后的值
planOrderCount int = 0
//调整后的货品总数,混合相加计算预计值和调整值中的一个,优先取调整值计算
useOrderCount int = 0
//订单的货品列表中是否存在调整货品数量
HasUseOrderCount bool = false
)
//调整后的合伙人分红,混合相加计算预计值和调整值中的一个,优先取调整值计算
usePartnerBonus := decimal.NewFromFloat(0)
//订单的货品列表中是否存在调整的合伙人分红
var hasUsePartnerBonus bool = false
//调整后的订单总额,混合相加计算预计值和调整值中的一个,优先取调整值计算
useOrderAmount := decimal.NewFromFloat(0)
var hasUseOrderAmount bool = false
//已支付分红
partnerBonusHas := decimal.NewFromFloat(0)
//未支付分红
partnerBonusNot := decimal.NewFromFloat(0)
//分红支出
partnerBonusExpense := decimal.NewFromFloat(0)
//初始订单的支付状态
order.BonusStatus = OrderGoodWaitPay
... ... @@ -215,14 +224,20 @@ func (order *OrderBase) Compute() error {
for i := range order.Goods {
if order.Goods[i].BonusStatus == OrderGoodHasPay {
//确定订单的支付状态
//订单的货品列表中“存在”支付状态的为已支付,则整体订单设定为已支付状态
order.BonusStatus = OrderGoodHasPay
}
//计算预计的合伙人分红,不含调整的值
planPartnerBonus = planPartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
//计算预计的订单总金额,不含调整的值
planOrderAmount = planOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
//计算预计的订单中货品总数,不含调整的值
planOrderCount += order.Goods[i].PlanGoodNumber
//获取调整货品调整后(数量)的总金额,
goodUseAmount := decimal.NewFromFloat(order.Goods[i].GoodCompute.UseAmount)
if goodUseAmount.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
//调整值非负值得情况
//调整后货品总金额,非负值(大于等于0)的情况
hasUseOrderAmount = true
useOrderAmount = useOrderAmount.Add(goodUseAmount)
} else {
... ... @@ -230,12 +245,14 @@ func (order *OrderBase) Compute() error {
}
goodUsePartnerBonus := decimal.NewFromFloat(order.Goods[i].GoodCompute.UsePartnerBonus)
if goodUsePartnerBonus.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
//货品中存在调整后的合伙人分红,即调整大于等于0
hasUsePartnerBonus = true
usePartnerBonus = usePartnerBonus.Add(goodUsePartnerBonus)
} else {
usePartnerBonus = usePartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
}
if order.Goods[i].UseGoodNumber >= 0 {
//货品中存在调整后的数量,调整值大于等于0
HasUseOrderCount = true
useOrderCount += order.Goods[i].UseGoodNumber
} else {
... ...
... ... @@ -311,6 +311,7 @@ func (good *OrderGood) Compute() error {
planamount := price.Mul(decimal.NewFromInt(int64(planGoodNumber)))
var partnerBonusPercent float64
if good.PartnerBonusPercent < 0 {
//判断合伙人分成比例是否设置,若未设置则按照 0 来计算分成
partnerBonusPercent = 0
} else {
partnerBonusPercent = good.PartnerBonusPercent
... ...