|
@@ -81,22 +81,21 @@ class CommissionService extends BaseService {
|
|
|
try {
|
|
|
if (order && order.inviter_id > 0) {
|
|
|
// 2022/11/18 获取配置分佣比例
|
|
|
- const keys = [ 'shop_commission_ratio', 'partner_commission_ratio', 'not_commission_category',
|
|
|
+ const keys = [ 'shop_commission_ratio', 'employee_commission_ratio', 'not_commission_category',
|
|
|
'special_sale_category', 'sale_commission_ratio' ];
|
|
|
const config = await that.service.configs.getConfigMoreValue(keys);
|
|
|
- let ratioDefault = 0;
|
|
|
- let ratioPartner = 0;
|
|
|
+ let ratioEmployee = 0.01;
|
|
|
+ let ratioDefault = 0.05;
|
|
|
let ratioSpecialSale = 0;
|
|
|
- let saleCategoryId = 15;
|
|
|
- // 2023/4/18 邀请人餐店合伙信息
|
|
|
- const partnerInfo = await that.app.model.PartnerInfo.findOne({
|
|
|
+ let saleCategoryId = 8;
|
|
|
+ // 2023/4/18 邀请人个人信息
|
|
|
+ const inviterInfo = await that.app.model.Users.findOne({
|
|
|
where: { user_id: order.inviter_id },
|
|
|
});
|
|
|
- // 2023/4/18 : 餐店 套餐推广 category_id 分佣比例特殊处理 partner_commission_ratio
|
|
|
- ratioPartner = Number(config.partner_commission_ratio);
|
|
|
- ratioDefault = Number(config.shop_commission_ratio);
|
|
|
- ratioSpecialSale = Number(config.sale_commission_ratio);
|
|
|
- saleCategoryId = Number(config.special_sale_category);
|
|
|
+ ratioEmployee = Number(config.employee_commission_ratio) ? Number(config.employee_commission_ratio) : 0.01;
|
|
|
+ ratioDefault = Number(config.shop_commission_ratio) ? Number(config.shop_commission_ratio) : 0.05;
|
|
|
+ ratioSpecialSale = Number(config.sale_commission_ratio) ? Number(config.sale_commission_ratio) : 0;
|
|
|
+ saleCategoryId = Number(config.special_sale_category) ? Number(config.special_sale_category) : 8;
|
|
|
const temA = config.not_commission_category.replace('[', '');
|
|
|
const temB = temA.replace(']', '');
|
|
|
let notCommissionCategory = temB.split(',');
|
|
@@ -109,9 +108,9 @@ class CommissionService extends BaseService {
|
|
|
if (saleCategoryId === order.orders_products[i].category_id) {
|
|
|
// 2023/5/24 特销产品分佣
|
|
|
commission += order.orders_products[i].total_price * ratioSpecialSale;
|
|
|
- } else if (partnerInfo && partnerInfo.category_id === order.orders_products[i].category_id) {
|
|
|
- // 2023/4/18 餐店推广自己的分类套餐 分佣比例有区别
|
|
|
- commission += order.orders_products[i].total_price * ratioPartner;
|
|
|
+ } else if (inviterInfo && inviterInfo.is_employee == true) {
|
|
|
+ // 2023/4/18 店员分佣比例有区别
|
|
|
+ commission += order.orders_products[i].total_price * ratioEmployee;
|
|
|
} else {
|
|
|
commission += order.orders_products[i].total_price * ratioDefault;
|
|
|
}
|