Compare commits

...

73 Commits
main ... rose

Author SHA1 Message Date
mkm
42afe19d91 Merge pull request 'dev' (#106) from dev into rose
Reviewed-on: #106
2024-08-06 11:25:20 +08:00
mkm
07e1f331ce Merge pull request 'feat: 添加存储库产品逻辑和店铺存储发送功能' (#104) from dev into rose
Reviewed-on: #104
2024-08-05 14:14:49 +08:00
mkm
d2ecc8a166 Merge pull request 'feat(StoreBranchProductLists): Update product list logic, optimize search conditions, adjust product query fields' (#102) from dev into rose
Reviewed-on: #102
2024-08-04 17:58:56 +08:00
mkm
dadeb89d09 Merge pull request 'feat(StoreProductController, WarehouseProductLists, StoreStorageSend): Update stock management logic, optimize inventory checking, adjust storage management methods' (#101) from dev into rose
Reviewed-on: #101
2024-08-04 17:51:17 +08:00
mkm
5f3e18fe83 Merge pull request 'feat(StoreProductController, WarehouseProductLists, StoreStorageSend): Update stock management logic, optimize inventory checking, adjust storage management methods' (#100) from dev into rose
Reviewed-on: #100
2024-08-04 17:41:48 +08:00
mkm
60ee9295c6 Merge pull request 'feat(StoreOrderLists): 更新订单列表处理逻辑,优化已支付订单显示方式,调整支付状态筛选条件' (#99) from dev into rose
Reviewed-on: #99
2024-08-04 14:26:48 +08:00
mkm
9fc4095563 Merge pull request 'dev' (#98) from dev into rose
Reviewed-on: #98
2024-08-04 13:13:32 +08:00
mkm
188904a63b Merge pull request 'dev' (#96) from dev into rose
Reviewed-on: #96
2024-08-03 21:18:07 +08:00
mkm
cbfcfb70cd Merge pull request 'feat: 修改日志处理类以支持不同级别的日志文件' (#95) from dev into rose
Reviewed-on: #95
2024-08-03 14:05:00 +08:00
mkm
bc385e3c2f Merge pull request 'feat: 增加查询已支付订单的条件' (#93) from dev into rose
Reviewed-on: #93
2024-08-03 11:37:33 +08:00
mkm
93969124e2 Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into rose 2024-08-03 11:26:11 +08:00
mkm
f120ad28be Merge pull request 'feat(StoreOrderCartInfoGroupLists, StoreOrderCartInfoTwoLists): 优化了商品单位、分类和店铺名称的获取方式,增加了空值处理' (#82) from erp into rose
Reviewed-on: #82
2024-08-02 19:58:21 +08:00
mkm
b7ea08c41c Merge pull request 'feat(StoreOrderCartInfoController): 添加了列表二功能及对应搜索条件' (#81) from erp into rose
Reviewed-on: #81
2024-08-02 19:46:23 +08:00
mkm
4e9857d9f5 Merge pull request 'feat: 增加根据条件筛选订单功能' (#80) from erp into rose
Reviewed-on: #80
2024-08-02 17:48:33 +08:00
mkm
57997f4a19 Merge remote-tracking branch 'origin/dev' into rose 2024-08-02 15:53:54 +08:00
mkm
e36c9416c4 Merge pull request '1' (#77) from erp into rose
Reviewed-on: #77
2024-08-02 11:02:42 +08:00
mkm
37c9cbd064 Merge pull request 'erp' (#76) from erp into rose
Reviewed-on: #76
2024-08-01 22:54:19 +08:00
mkm
4711643bb8 Merge pull request 'feat(SystemStoreStorageLists): 优化了系统商店存储列表的商品名称和图片获取方式' (#75) from erp into rose
Reviewed-on: #75
2024-08-01 16:53:53 +08:00
mkm
af6e8e2387 Merge pull request 'feat: 修改仓库产品逻辑和库存发送队列,增加财务PM判断逻辑' (#74) from erp into rose
Reviewed-on: #74
2024-08-01 16:47:05 +08:00
mkm
55daad5815 Merge pull request 'feat: 添加仓库信息功能' (#73) from erp into rose
Reviewed-on: #73
2024-08-01 15:46:53 +08:00
mkm
a54adbd928 Merge pull request 'erp' (#72) from erp into rose
Reviewed-on: #72
2024-08-01 14:06:51 +08:00
mkm
bc40d950aa Merge pull request 'feat(store_order): 添加查询订单支付状态功能' (#70) from dev into rose
Reviewed-on: #70
2024-07-31 12:00:16 +08:00
mkm
14d1ca8c11 Merge pull request 'feat(PayNotifyLogic): 添加订单支付成功推送通知功能' (#69) from dev into rose
Reviewed-on: #69
2024-07-31 11:45:06 +08:00
mkm
f451525aa9 Merge pull request 'dev' (#68) from dev into rose
Reviewed-on: #68
2024-07-31 11:26:37 +08:00
mkm
17464ff077 feat: 修改了订单逻辑和佣金产品逻辑,增加了对商品的库存检查,并优化了支付通知逻辑。 2024-07-30 16:47:22 +08:00
mkm
522af410cd feat: 增加推广用户等级判断逻辑 2024-07-30 14:27:08 +08:00
mkm
27f424be34 Merge pull request 'dev' (#66) from dev into rose
Reviewed-on: #66
2024-07-30 10:26:53 +08:00
mkm
1f336cc6e2 Merge pull request 'feat: 修改OrderWetchaPushSend类以优化商品信息格式' (#64) from dev into rose
Reviewed-on: #64
2024-07-29 17:16:36 +08:00
mkm
db336e476f Merge pull request 'feat(OrderWetchaPushSend.php): 修改商品信息展示,增加单位显示' (#63) from dev into rose
Reviewed-on: #63
2024-07-29 17:11:58 +08:00
mkm
f55d444799 feat(CommissionProductLogic): 修改了CommissionProductLogic类中的判断条件,移除了用户船只类型5的判断,改为判断商品的顶级分类ID是否为15189。 2024-07-29 17:09:05 +08:00
mkm
665f56cee9 feat: 修改CommissionProductLogic类以支持更多用户船舶类型 2024-07-29 16:52:51 +08:00
mkm
c4e69f99f7 Merge branch 'rose' of https://gitea.lihaink.cn/mkm/multi-store into rose 2024-07-29 16:37:12 +08:00
mkm
a89a555f7c fix: 修正产品佣金逻辑错误 2024-07-29 16:37:05 +08:00
mkm
0d86926915 Merge pull request 'dev' (#62) from dev into rose
Reviewed-on: #62
2024-07-29 16:16:41 +08:00
mkm
b48ed7d80e Merge branch 'rose' of https://gitea.lihaink.cn/mkm/multi-store into rose 2024-07-29 16:16:08 +08:00
mkm
c3d1de3671 feat: 添加新功能计算产品佣金 2024-07-29 16:16:02 +08:00
mkm
a790577276 Merge pull request 'dev' (#61) from dev into rose
Reviewed-on: #61
2024-07-29 14:43:37 +08:00
mkm
3cc738e6c3 feat: 移除了CommissionProductLogic中的调试代码 2024-07-27 18:05:14 +08:00
mkm
8e2e9c0fa8 feat: 修改产品佣金计算逻辑 2024-07-27 18:00:44 +08:00
mkm
9117e3eb89 feat: 修改CommissionProductLogic类以计算佣金 2024-07-27 17:41:32 +08:00
mkm
6ddcab62b6 feat: 修改CommissionProductLogic类的a方法 2024-07-27 17:32:41 +08:00
mkm
58423f1b01 feat: 修改了CommissionProductLogic类中的计算逻辑,根据用户等级和商品rose值进行不同的计算和存储操作。 2024-07-27 17:27:52 +08:00
mkm
b5e2707c3c feat: 调整佣金计算逻辑以区分门店和平台收入 2024-07-27 17:06:03 +08:00
mkm
fcf6efe6ae refactor: 调整代码风格和格式 2024-07-27 16:45:26 +08:00
mkm
8056fce1da feat(CommissionLogic): 根据订单类型和ID查询费用并记录用户余额收入 2024-07-27 16:41:36 +08:00
mkm
8d0b39c8e0 feat: 修改CommissionProductLogic以处理不同类型的用户 2024-07-27 16:35:12 +08:00
mkm
46fdf20b47 feat: 修改CommissionProductLogic类以调整分销逻辑 2024-07-27 16:12:33 +08:00
mkm
665c8e89d2 feat: 修改计算商品流程方法,优化了代码结构,并调整了参数,使其更符合逻辑。 2024-07-27 15:55:10 +08:00
mkm
527dd756ec feat: 新增分享获得还功能 2024-07-27 15:23:01 +08:00
mkm
b141ac8fad feat(OrderLogic): 修正用户地址队伍拼接错误 2024-07-27 14:59:53 +08:00
mkm
ac6d03f7b5 Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into rose 2024-07-27 14:59:19 +08:00
mkm
1a884b691e Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into rose 2024-07-27 14:53:13 +08:00
mkm
227de2fe30 feat: 简化支付通知逻辑 2024-07-27 11:55:04 +08:00
mkm
518d9fe064 Merge branch 'rose' of https://gitea.lihaink.cn/mkm/multi-store into rose 2024-07-27 11:52:44 +08:00
mkm
99dc835cb1 feat: 添加'开通时间'字段到用户列表,修改线下分润、支付通知等逻辑 2024-07-27 11:52:31 +08:00
mkm
c1a0b6adec Merge pull request 'feat(OrderEnum): 根据订单状态和退款状态更新订单类型' (#60) from dev into rose
Reviewed-on: #60
2024-07-27 10:16:58 +08:00
mkm
81072d2859 Merge pull request 'feat(OrderEnum): 添加退货状态查询功能' (#59) from dev into rose
Reviewed-on: #59
2024-07-27 10:13:28 +08:00
mkm
af37f15da3 Merge pull request 'feat: 修改StoreOrder模型以处理订单状态的获取逻辑' (#58) from dev into rose
Reviewed-on: #58
2024-07-27 10:10:56 +08:00
mkm
f8806b8ada Merge pull request 'feat(PayNotifyLogic): 修改用户支付通知逻辑,调整资金流动记录' (#57) from dev into rose
Reviewed-on: #57
2024-07-27 09:46:57 +08:00
mkm
49f7e50644 Merge pull request 'feat: 增加对余额支付的处理逻辑' (#56) from dev into rose
Reviewed-on: #56
2024-07-27 09:35:17 +08:00
mkm
953b7db733 Merge pull request 'dev' (#55) from dev into rose
Reviewed-on: #55
2024-07-27 09:25:33 +08:00
mkm
eae37a1142 feat: 移除调试代码增加代码整洁性 2024-07-26 17:39:03 +08:00
mkm
ddc9a82766 feat(order): 增加订单参数打印调试 2024-07-26 17:38:47 +08:00
mkm
279cc7d903 feat: 修改订单逻辑以更新商品统计记录和财务流水 2024-07-26 16:53:35 +08:00
mkm
9bc69d71fe feat: 添加了订单财务流产品模型 2024-07-26 16:39:28 +08:00
mkm
6d6374db71 feat: 修改CommissionProductLogic和PayNotifyLogic类以计算商品流通 2024-07-26 16:00:51 +08:00
mkm
a92f33d490 feat: 修改CommissionProductLogic计算佣金产品逻辑 2024-07-26 15:32:24 +08:00
mkm
83f81a3974 feat: 修改分润逻辑以优化计算方式 2024-07-26 15:06:47 +08:00
mkm
5cf7dd76b9 feat: 移除用户余额收入记录代码 2024-07-26 11:51:30 +08:00
mkm
0d10483162 Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into rose 2024-07-26 11:37:22 +08:00
mkm
30230df638 feat(CommissionProductLogic): 根据毛利率计算分配产品流水 2024-07-25 17:59:15 +08:00
mkm
1ffd1193c1 feat: 添加了根据毛利率计算产品流的功能 2024-07-25 17:33:05 +08:00
mkm
78aa37bb3b feat: 修改了OrderLogic和PayNotifyLogic类,添加了'rose'字段查询和支付通知逻辑。 2024-07-25 11:41:49 +08:00
7 changed files with 328 additions and 154 deletions

View File

@ -150,7 +150,8 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface,ListsS
'store_name' => '门店',
'total_recharge_amount' => '累计消费',
'purchase_funds' => '采购款',
'format_address'=>'地址'
'format_address'=>'地址',
'vip_time'=>'开通时间'
];
}
}

View File

@ -47,6 +47,7 @@ class OrderEnum
const PURCHASE_FUNDS = 18;//采购款收银
const USER_ORDER_REFUND = 19;//订单返还
const SHARE_ORDER_OBTAINS = 20;//分享获得还
const PAY_BACK =-1;
@ -166,7 +167,8 @@ class OrderEnum
self::ORDER_MARGIN=>'保证金',
self::VIP_ORDER_OBTAINS=>'会员',
self::OTHER_ORDER_OBTAINS=>'其他',
self::USER_ORDER_REFUND=>'订单返还'
self::USER_ORDER_REFUND=>'订单返还',
self::SHARE_ORDER_OBTAINS=>'分享'
];
if ($value === true) {

View File

@ -3,6 +3,7 @@
namespace app\common\logic;
use app\common\enum\OrderEnum;
use app\common\model\store_finance_flow_product\StoreFinanceFlowProduct;
use app\common\model\system_store\SystemStore;
use app\common\model\user\User;
use app\common\model\user\UserAddress;
@ -14,79 +15,81 @@ class CommissionLogic extends BaseLogic
*/
public static function setVillage($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0)
{
$user_1 = self::user($order, 0.05, $transaction_id, $village_uid, 14); //村长
$user_2 = self::user($order, 0.03, $transaction_id, 0, 12); //会员、厨师
$user_3 = self::user($order, 0.01, $transaction_id, $brigade_uid, 15); //队长
self::user($order, 3, $transaction_id, $village_uid, 14); //村长
self::user($order, 0, $transaction_id, 0, 12); //会员、厨师
self::user($order, 5, $transaction_id, 0, 20); //个人店铺
self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长
$platform = self::platform($order, 0.02, $transaction_id); //平台
$store = self::store($order, 0.05, $transaction_id, 0); //门店
$attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗
$moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2);
self::suppliter($order, $moeny, $transaction_id);
self::platform($order, 2, $transaction_id); //平台
self::store($order, 1, $transaction_id, 0); //门店
// $attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗
self::suppliter($order, $transaction_id);
}
/**
* 走队长分润
*/
public static function setBrigade($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0)
{
$user_1 = self::user($order, 0.05, $transaction_id, $brigade_uid, 15); //队长
$user_2 = self::user($order, 0.03, $transaction_id, 0, 12); ////会员、厨师
$user_3 = self::user($order, 0.01, $transaction_id, $village_uid, 14); //村长
self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长
self::user($order, 0, $transaction_id, 0, 12); ////会员、厨师
self::user($order, 5, $transaction_id, 0, 20); ////会员、厨师
self::user($order, 3, $transaction_id, $village_uid, 14); //村长
$platform = self::platform($order, 0.02, $transaction_id); //平台
$store = self::store($order, 0.05, $transaction_id, 0); //门店
$attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗
$moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2);
self::suppliter($order, $moeny, $transaction_id);
self::platform($order, 2, $transaction_id); //平台
self::store($order, 1, $transaction_id, 0); //门店
// $attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗
self::suppliter($order, $transaction_id);
}
/**
* 走厨师分润
*/
public static function setCook($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0)
{
if($order['spread_uid']<=0){
$uid=$order['uid'];
}else{
$uid=$order['spread_uid'];
if ($order['spread_uid'] <= 0) {
$uid = $order['uid'];
} else {
$uid = $order['spread_uid'];
}
$user_1 = self::user($order, 0.07, $transaction_id, $uid, 12); //会员、厨师
$user_2 = self::user($order, 0.01, $transaction_id, $village_uid, 14); //村长
$user_3 = self::user($order, 0.01, $transaction_id, $brigade_uid, 15); //队长
$platform = self::platform($order, 0.02, $transaction_id); //平台
$store = self::store($order, 0.05, $transaction_id, 0); //门店
$attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗
$moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2);
self::suppliter($order, $moeny, $transaction_id);
self::user($order, 0, $transaction_id, $uid, 12); //会员、厨师
self::user($order, 5, $transaction_id, $uid, 20); //会员、厨师
self::user($order, 3, $transaction_id, $village_uid, 14); //村长
self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长
self::platform($order, 2, $transaction_id); //平台
self::store($order, 1, $transaction_id, 0); //门店
// $attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗
// $moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, 0, 2), 2);
self::suppliter($order, $transaction_id);
}
/**
* 走线下分润
* 零售分润
*/
public static function setStore($order, $transaction_id = 0)
public static function setStore($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0)
{
$platform = self::platform($order, 0.02, $transaction_id); //平台
$store = self::store($order, 0.05, $transaction_id, 0); //门店
$attrition = self::attrition($order, 0.01, $transaction_id, 16); //损耗
$moeny = bcadd(bcadd($platform, $store, 2), $attrition, 2);
self::suppliter($order, $moeny, $transaction_id);
if ($order['spread_uid'] <= 0) {
$uid = $order['uid'];
} else {
$uid = $order['spread_uid'];
}
self::user($order, 0, $transaction_id, $uid, 12); //会员、厨师
self::user($order, 5, $transaction_id, $uid, 20); //会员、厨师
self::user($order, 3, $transaction_id, $village_uid, 14); //村长
self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长
self::platform($order, 2, $transaction_id); //平台
self::store($order, 1, $transaction_id, 0); //门店
self::suppliter($order, $transaction_id);
}
/**
* 平台分润
*/
public static function platform($order, $platformRate, $transaction_id)
public static function platform($order, $type, $transaction_id)
{
$financeLogic = new StoreFinanceFlowLogic();
$financeLogic->order = $order;
$financeLogic->user['uid'] = $order['uid'];
$pay_price = $order['pay_price'];
if (isset($order['dealVipAmount']) && $order['dealVipAmount'] > 0) {
$pay_price = bcsub($order['pay_price'], $order['dealVipAmount'], 2);
}
$fees = bcdiv(bcmul($pay_price, $platformRate, 2), 1, 2);
$fees = StoreFinanceFlowProduct::where('oid', $order['id'])->where('type', $type)->sum('number');
if ($fees > 0) {
$financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费
$financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出
@ -97,16 +100,14 @@ class CommissionLogic extends BaseLogic
/**
* 供应链订单获得
*/
public static function suppliter($order, $platformRate, $transaction_id)
public static function suppliter($order, $transaction_id)
{
$financeLogic = new StoreFinanceFlowLogic();
$financeLogic->order = $order;
$financeLogic->user['uid'] = $order['uid'];
$pay_price = $order['pay_price'];
if (isset($order['dealVipAmount']) && $order['dealVipAmount'] > 0) {
$pay_price = bcsub($order['pay_price'], $order['dealVipAmount'], 2);
}
$fees = bcsub($pay_price, $platformRate, 2);
$number = StoreFinanceFlowProduct::where('oid', $order['id'])->sum('number');
$fees = bcsub($pay_price, $number, 2);
if ($fees > 0) {
$financeLogic->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
@ -116,7 +117,7 @@ class CommissionLogic extends BaseLogic
/**
* 门店分润
*/
public static function store($order, $platformRate, $transaction_id, $uid)
public static function store($order, $type, $transaction_id, $uid)
{
$financeLogic = new StoreFinanceFlowLogic();
$financeLogic->user['uid'] = $order['uid'];
@ -127,11 +128,7 @@ class CommissionLogic extends BaseLogic
//缴纳齐全了就加商户没有就加到平台
$money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find();
$deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度
$pay_price = $order['pay_price'];
if (isset($order['dealVipAmount']) && $order['dealVipAmount'] > 0) {
$pay_price = bcsub($order['pay_price'], $order['dealVipAmount'], 2);
}
$store_profit = bcmul($pay_price, $platformRate, 2);
$store_profit = StoreFinanceFlowProduct::where('oid', $order['id'])->where('type', $type)->sum('number');
if ($deposit > 0) {
if ($deposit > $store_profit) {
if ($store_profit > 0) {
@ -159,47 +156,20 @@ class CommissionLogic extends BaseLogic
/**
* 分给用户
*/
public static function user($order, $userRate, $transaction_id, $uid = 0, $enum = 0)
public static function user($order, $type, $transaction_id, $uid = 0, $enum = 0)
{
$financeLogic = new StoreFinanceFlowLogic();
$pay_price = $order['pay_price'];
if (isset($order['dealVipAmount']) && $order['dealVipAmount'] > 0) {
$pay_price = bcsub($order['pay_price'], $order['dealVipAmount'], 2);
}
$fees = bcmul($pay_price, $userRate, 2);
if ($fees > 0) {
$fees = StoreFinanceFlowProduct::where('oid', $order['id'])->where('type', $type)->field('sum(number) as fees,other_uid')->find();
if ($fees && $fees['fees'] > 0) {
//记录用户余额收入
// if ($uid) {
// if(in_array($enum,[14,15])&&$userRate==0.05){
// $purchase_funds=User::where('id', $uid)->value('purchase_funds');
// if($purchase_funds>0){
// $fees_two = bcmul($purchase_funds, $userRate, 2);
// if($fees_two<$fees){
// $fees=$fees_two;
// }
// }
// }
// if($enum==12&&$userRate==0.07){
// $purchase_funds=User::where('id', $uid)->value('purchase_funds');
// if($purchase_funds>0){
// $fees_two = bcmul($purchase_funds, $userRate, 2);
// if($fees_two<$fees){
// $fees=$fees_two;
// }
// }
// }
// $GiveUser = User::where('id', $order['uid'])->find();
// $capitalFlowDao = new CapitalFlowLogic($GiveUser);
// $capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees);
// }
$financeLogic->user['uid'] = $order['uid'];
$financeLogic->other_arr['vip_uid'] = $uid;
$financeLogic->other_arr['vip_uid'] = $fees['other_uid'];
$financeLogic->order = $order;
$financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->out($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->in($transaction_id, $fees['fees'], $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->out($transaction_id, $fees['fees'], $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->save();
}
return $fees;
return $fees['fees'];
}
/**

View File

@ -0,0 +1,175 @@
<?php
namespace app\common\logic;
use app\common\model\distribution\Distribution;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_finance_flow_product\StoreFinanceFlowProduct;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product\StoreProduct;
use PDO;
/**
* 产品佣金计算
*
*/
class CommissionProductLogic extends BaseLogic
{
/**
* 根据毛利率计算
*/
function calculate_product_flow($find, $order, $village_uid = 0, $brigade_uid = 0, $user_ship = 0, $spread_user_ship = 0)
{
$product = StoreProduct::where('id', $find['product_id'])->find();
if ($product && $product['rose'] > 0) {
if (in_array($user_ship, [4, 6, 7])) {
$this->b($find, $order, $product);
return true;
}
if ($product['rose'] < 8) {
return false;
} else {
if($user_ship==5){
$top_cate_id=StoreBranchProduct::where('product_id',$find['product_id'])->value('top_cate_id');
if($top_cate_id==15189){
$this->b($find, $order, $product);
return true;
}
}
$this->a($find, $order, $village_uid, $brigade_uid, $user_ship, $product);
}
return true;
}
}
/**
* 零售价结算
*/
public function a($find, $order, $village_uid, $brigade_uid, $user_ship, $product)
{
$rose = bcdiv($product['rose'], 100, 2);
$total_price = bcmul($product['purchase'], $find['cart_num']);
$Distribution = Distribution::where('rate', $rose)->find();
//门店
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => bcmul($total_price, $Distribution['store'], 2),
'oid' => $order['id'],
'type' => 1,
'status' => 1,
];
//平台
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => bcmul($total_price, $Distribution['platform'], 2),
'oid' => $order['id'],
'type' => 2,
'status' => 1,
];
//村长
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid' => $village_uid,
'number' => bcmul($total_price, $Distribution['village'], 2),
'oid' => $order['id'],
'type' => 3,
'status' => 1,
];
//队长
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid' => $brigade_uid,
'number' => bcmul($total_price, $Distribution['brigade'], 2),
'oid' => $order['id'],
'type' => 4,
'status' => 1,
];
//会员
if ($user_ship == 1) {
$uid = $order['spread_uid'];
} else {
$uid = 0;
}
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid' => $uid,
'number' => bcmul($total_price, $Distribution['user'], 2),
'oid' => $order['id'],
'type' => 0,
'status' => 1,
];
//个人店铺
if ($order['spread_uid'] > 0) {
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid' => $order['spread_uid'],
'number' => bcmul($total_price, $Distribution['person_store'], 2),
'oid' => $order['id'],
'type' => 5,
'status' => 1,
];
}
(new StoreFinanceFlowProduct())->saveAll($data);
}
/**
* 商户价结算
*/
public function b($find, $order, $product)
{
// $rose = bcdiv($product['rose'], 100, 2);
$total_price = bcmul($product['purchase'], $find['cart_num']);
$commission = bcmul($total_price, 0.02, 2);
//供货价
$total_cost = bcmul($product['cost'], $find['cart_num']);
$total = bcsub($total_cost, $total_price, 2);
$number = bcsub($total, $commission, 2);
if ($product['rose'] <= 4) {
//门店
$data = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => $total,
'oid' => $order['id'],
'type' => 1,
'status' => 1,
];
StoreFinanceFlowProduct::create($data);
} else {
//门店
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => $number,
'oid' => $order['id'],
'type' => 1,
'status' => 1,
];
//平台
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => $commission,
'oid' => $order['id'],
'type' => 2,
'status' => 1,
];
(new StoreFinanceFlowProduct())->saveAll($data);
}
}
}

View File

@ -95,7 +95,7 @@ class PayNotifyLogic extends BaseLogic
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 3, $order['store_id']);
self::dealProductLog($order);
self::afterPay($order);
if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) {
$checkArr = [
@ -104,7 +104,7 @@ class PayNotifyLogic extends BaseLogic
];
self::dealGoodsLeft($checkArr, $order['uid'], $order['id']);
}
if ($order && $order['store_id'] && $order['reservation'] !=1 && $order['source']==1) {
if ($order && $order['store_id'] && $order['reservation'] != 1 && $order['source'] == 1) {
$params = [
'verify_code' => $order['verify_code'],
'store_id' => $order['store_id'],
@ -112,7 +112,7 @@ class PayNotifyLogic extends BaseLogic
];
OrderLogic::writeOff($params);
}
if(in_array($order['shipping_type'],[1,2])){
if (in_array($order['shipping_type'], [1, 2])) {
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
}
return true;
@ -201,7 +201,7 @@ class PayNotifyLogic extends BaseLogic
// }
// self::addUserSing($order);
self::afterPay($order);
if ($order && $order['store_id'] && $order['reservation'] !=1 && $order['source']==1) {
if ($order && $order['store_id'] && $order['reservation'] != 1 && $order['source'] == 1) {
$params = [
'verify_code' => $order['verify_code'],
'store_id' => $order['store_id'],
@ -219,7 +219,7 @@ class PayNotifyLogic extends BaseLogic
}
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
if(in_array($order['shipping_type'],[1,2])){
if (in_array($order['shipping_type'], [1, 2])) {
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
}
}
@ -438,7 +438,7 @@ class PayNotifyLogic extends BaseLogic
$uid = $order->uid;
$user = User::where('id', $uid)->findOrEmpty();
//check store_id
if($user->store_id==0){
if ($user->store_id == 0) {
$user->store_id = $order['store_id'];
}
@ -455,7 +455,7 @@ class PayNotifyLogic extends BaseLogic
//更新等级
$user->user_ship = $order['user_ship'];
if($user['vip_time']==null){
if ($user['vip_time'] == null) {
$user->vip_time = time();
}
$user->purchase_funds = bcadd($user->purchase_funds, $price, 2);
@ -487,7 +487,7 @@ class PayNotifyLogic extends BaseLogic
$order->paid = 1;
$order->pay_time = time();
$order->status = 2;
if ($order['reservation'] ==1) {
if ($order['reservation'] == 1) {
$order->status = 1;
}
if (!$order->save()) {
@ -501,7 +501,7 @@ class PayNotifyLogic extends BaseLogic
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
self::dealProductLog($order);
if ($order && $order['store_id'] && $order['reservation'] !=1) {
if ($order && $order['store_id'] && $order['reservation'] != 1) {
$params = [
'verify_code' => $order['verify_code'],
'store_id' => $order['store_id'],
@ -569,6 +569,7 @@ class PayNotifyLogic extends BaseLogic
$village_uid = 0;
$brigade_uid = 0;
$user_ship = 0;
$spread_user_ship = 0;
$order['dealVipAmount'] = 0;
try {
if($order['uid']!=1){
@ -583,10 +584,9 @@ class PayNotifyLogic extends BaseLogic
//用户下单该用户等级为1得时候才处理冻结金额
$user = User::where('id', $order['uid'])->find();
$user_ship = $user['user_ship'];
}
//积分写入
if(isset($user) && $user['user_ship']==0){
if (isset($user) && $user['user_ship'] == 0) {
UserSignLogic::OrderWrite($order);
}
if ($off_activity == 1) {
@ -604,43 +604,28 @@ class PayNotifyLogic extends BaseLogic
// if ($user_ship>0 && $order['pay_type'] != PayEnum::CASH_PAY && $off_activity !=1) {
// $order['dealVipAmount']= self::dealVipAmount($order, $order['pay_type']);
// }
if ($order['spread_uid'] > 0 || $user_ship > 0) {
if ($order['spread_uid'] > 0 && $user_ship == 0) {
$user_ship = User::where('id', $order['spread_uid'])->value('user_ship');
if ($user_ship == 2) {
$village_uid = $order['spread_uid'];
$address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find();
if ($address) {
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
if ($arr2) {
$brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0;
}
if ($order['spread_uid'] > 0 && $user_ship == 0) {
$spread_user_ship = User::where('id', $order['spread_uid'])->value('user_ship');
if ($spread_user_ship == 2) {
$village_uid = $order['spread_uid'];
$address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find();
if ($address) {
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
if ($arr2) {
$brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0;
}
} elseif ($user_ship == 3) {
$brigade_uid = $order['spread_uid'];
$address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find();
if ($address) {
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
if ($arr1) {
$village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0;
}
}
}else{
$address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find();
if ($address) {
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
if ($arr1) {
$village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0;
}
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
if ($arr2) {
$brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0;
}
}
} elseif ($spread_user_ship == 3) {
$brigade_uid = $order['spread_uid'];
$address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find();
if ($address) {
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
if ($arr1) {
$village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0;
}
}
} else {
//查询用户对应的村长和队长
$address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find();
$address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find();
if ($address) {
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
if ($arr1) {
@ -652,28 +637,27 @@ class PayNotifyLogic extends BaseLogic
}
}
}
switch ($user_ship) {
case 1: // 厨师
//case 4: // 商户
//case 5: // 种养殖
// case 6: // 酒店
// case 7: // 食堂
case 8: // 一条龙
CommissionLogic::setCook($order, $village_uid, $brigade_uid, $transaction_id);
break;
case 2: // 村长
CommissionLogic::setVillage($order, $village_uid, $brigade_uid, $transaction_id);
break;
case 3: // 队长
CommissionLogic::setBrigade($order, $village_uid, $brigade_uid, $transaction_id);
break;
default:
CommissionLogic::setStore($order, $transaction_id);
break;
}
} else {
CommissionLogic::setStore($order, $transaction_id);
//查询用户对应的村长和队长
$address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find();
if ($address) {
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
if ($arr1) {
$village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0;
}
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
if ($arr2) {
$brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0;
}
}
}
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,cart_num')->select();
$comm = new CommissionProductLogic();
foreach ($info as $k=>$v) {
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid,$user_ship,$spread_user_ship);
}
CommissionLogic::setStore($order,$village_uid, $brigade_uid, $transaction_id);
return true;
}
/**

View File

@ -0,0 +1,22 @@
<?php
namespace app\common\model\distribution;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 角色分润规则模型
* Class distribution
* @package app\common\model\order
*/
class Distribution extends BaseModel
{
use SoftDelete;
protected $name = 'distribution';
protected $deleteTime = 'delete_time';
}

View File

@ -0,0 +1,20 @@
<?php
namespace app\common\model\store_finance_flow_product;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 财务流水商品明细
* Class StoreFinanceFlowProduct
* @package app\common\model\store_finance_flow_product
*/
class StoreFinanceFlowProduct extends BaseModel
{
use SoftDelete;
protected $name = 'store_finance_flow_product';
protected $deleteTime = 'delete_time';
}