分润功能log

This commit is contained in:
chenbo 2024-01-26 11:59:11 +08:00
parent 34d1914849
commit 75c65fd0f1
1 changed files with 15 additions and 6 deletions

View File

@ -4,6 +4,7 @@ namespace app\api\controller;
use app\adminapi\logic\user\UserLogic; use app\adminapi\logic\user\UserLogic;
use app\common\logic\ShopRequestLogic; use app\common\logic\ShopRequestLogic;
use app\common\model\user\User;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\facade\Log; use think\facade\Log;
@ -185,27 +186,35 @@ class ShopCallController extends BaseApiController
if (null === $requestDatas) { if (null === $requestDatas) {
return $this->fail('非法访问,解析失败'); return $this->fail('非法访问,解析失败');
} }
$streetCode = $requestDatas['data']['street_code']; // 镇街地区码 $streetCode = $requestDatas['data']['street_code']??''; // 镇街地区码
$orderMoney = $requestDatas['data']['order_money']; // 订单金额 分 $orderMoney = $requestDatas['data']['order_money']; // 订单金额 分
$orderNo = $requestDatas['data']['order_sn']; // 订单金额 $orderNo = $requestDatas['data']['order_sn']; // 订单金额
$orderId = $requestDatas['data']['order_id']; // 订单id $orderId = $requestDatas['data']['order_id']; // 订单id
$courierPhone = $requestDatas['data']['courier_phone']; // 配送员账号 $courierPhone = $requestDatas['data']['courier_phone']??''; // 配送员账号
// 镇合伙人 // 镇合伙人
$userSelf = UserLogic::getUser(['street'=>$streetCode, 'group_id'=>15]); $userSelf = new User();
if (!empty($streetCode)) {
$userSelf = UserLogic::getUser(['street'=>$streetCode, 'group_id'=>15]);
}
// 配送员 // 配送员
$courier = UserLogic::getUser(['account'=>$courierPhone]); $courier = new User();
if (!empty($courierPhone)) {
$courier = UserLogic::getUser(['account'=>$courierPhone]);
}
$proportion = 0.01; // 比例 $proportion = 0.01; // 比例
$noticeUser = []; $noticeUser = [];
// 计算分润 // 计算分润
if (!empty($userSelf)) { if (!$userSelf->isEmpty()) {
UserLogic::userProfit($userSelf, $orderMoney, $proportion, $orderNo); UserLogic::userProfit($userSelf, $orderMoney, $proportion, $orderNo);
$noticeUser[] = ['type' => 3, 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)]; $noticeUser[] = ['type' => 3, 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)];
} }
if (!empty($courier)) { if (!$courier->isEmpty()) {
UserLogic::userProfit($courier, $orderMoney, $proportion, $orderNo); UserLogic::userProfit($courier, $orderMoney, $proportion, $orderNo);
$noticeUser[] = ['type' => 4, 'account' => $courier['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)]; $noticeUser[] = ['type' => 4, 'account' => $courier['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)];
} }