完善小组人员分佣,增加分佣记录区分来源
This commit is contained in:
parent
4015a21417
commit
3b1fb1cda5
@ -230,6 +230,9 @@ class UserBillDao extends BaseDao
|
||||
->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) {
|
||||
$query->where('mer_id', $where['mer_id']);
|
||||
})
|
||||
->when(isset($where['source']) && $where['source'] !== '', function ($query) use ($where) {
|
||||
$query->where('source', $where['source']);
|
||||
})
|
||||
->when(isset($where['link_id']) && $where['link_id'] !== '', function ($query) use ($where) {
|
||||
$query->where('link_id', $where['link_id']);
|
||||
});
|
||||
|
@ -72,10 +72,12 @@ class UserBillRepository extends BaseRepository
|
||||
$this->dao = $dao;
|
||||
}
|
||||
|
||||
public function userList($where, $uid, $page, $limit)
|
||||
public function userList($where, $uid, $page, $limit, $source = 2)
|
||||
{
|
||||
$where['uid'] = $uid;
|
||||
$where['source'] = $source;
|
||||
$query = $this->dao->search($where)->order('create_time DESC');
|
||||
|
||||
$count = $query->count();
|
||||
$list = $query->setOption('field', [])->field('bill_id,pm,title,number,balance,mark,create_time,status')->page($page, $limit)->select();
|
||||
return compact('count', 'list');
|
||||
|
@ -80,7 +80,32 @@ class User extends BaseController
|
||||
$user = $this->user;
|
||||
$make = app()->make(UserBrokerageRepository::class);
|
||||
$user->append(['one_level_count', 'lock_brokerage', 'two_level_count', 'spread_total', 'yesterday_brokerage', 'total_extract', 'total_brokerage', 'total_brokerage_price']);
|
||||
|
||||
$show_brokerage = (bool)$make->search(['type' => 0])->count();
|
||||
|
||||
$source = $this->request->param('source');
|
||||
$source = !isset($source)?2:$source; // 默认来源为2 普通商品订单
|
||||
|
||||
// 小组采购佣金另外处理
|
||||
if($source == 1)
|
||||
{
|
||||
$data = [
|
||||
'total_brokerage_price' => $user->total_brokerage_price, // 可提现金额
|
||||
'total_extract' => $user->lock_brokerage, // 已提现金额
|
||||
'yesterday_brokerage' => $user->yesterday_brokerage, // 昨日提现收益
|
||||
'lock_brokerage' => $user->lock_brokerage, // 冻结中金额
|
||||
'spread_total' => $user->spread_total,
|
||||
'total_brokerage' => $user->total_brokerage,
|
||||
'brokerage_price' => $user->brokerage_price,
|
||||
'show_brokerage' => $show_brokerage,
|
||||
'broken_day' => (int)systemConfig('lock_brokerage_timer'),
|
||||
'user_extract_min' => (int)systemConfig('user_extract_min'),
|
||||
|
||||
];
|
||||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'total_brokerage_price' => $user->total_brokerage_price,
|
||||
'lock_brokerage' => $user->lock_brokerage,
|
||||
@ -163,10 +188,13 @@ class User extends BaseController
|
||||
*/
|
||||
public function brokerage_list(UserBillRepository $billRepository)
|
||||
{
|
||||
$source = $this->request->param('source');
|
||||
$source = !isset($source)?2:$source; // 默认来源为2 普通商品订单
|
||||
|
||||
[$page, $limit] = $this->getPage();
|
||||
return app('json')->success($billRepository->userList([
|
||||
'category' => 'brokerage',
|
||||
], $this->request->uid(), $page, $limit));
|
||||
], $this->request->uid(), $page, $limit, $source));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,7 @@ use think\facade\Log;
|
||||
use app\common\model\system\supplychain\SupplyChainBorkerage;
|
||||
use app\common\model\system\supplychain\SupplyChainTeam;
|
||||
use app\common\model\system\supplychain\SupplyChainLevel;
|
||||
use app\common\repositories\user\UserBillRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -62,9 +63,169 @@ class SupplyChainOrderBrokerAgeJob implements JobInterface
|
||||
|
||||
// 储存小组服务分佣记录
|
||||
$status = SupplyChainBorkerage::create($dataArr);
|
||||
// 增加小组服务佣金明细
|
||||
|
||||
\think\facade\Log::record($status);
|
||||
// 写入冻结佣金
|
||||
$userBillRepository = app()->make(UserBillRepository::class);
|
||||
|
||||
// 加入账单记录 佣金明细
|
||||
$userBillRepository->incBill($data['uid'], 'brokerage', 'order_one', [
|
||||
'link_id' => $data['order_id'],
|
||||
'status' => 0,
|
||||
'title' => '获得采购佣金',
|
||||
'number' => $usrPrice, // 增加金额
|
||||
'mark' => $data['order_sn'] . '采购:' . $data['inc'] . '元,获得采购佣金' . $usrPrice,
|
||||
'balance' => 0,
|
||||
'source' => 1 // 1 小组采购 2 普通商品
|
||||
]);
|
||||
|
||||
$userRepository = app()->make(UserRepository::class);
|
||||
|
||||
// 增加
|
||||
$userRepository->incBrokerage($data['uid'], $price);
|
||||
|
||||
// 增加小组服务佣金明细
|
||||
// $onePrice = '0.00'; // 一级佣金
|
||||
// $twoPrice = '0.00'; // 二级佣金
|
||||
// $threePrice = '0.00'; // 三级佣金
|
||||
// $fourPrice = '0.00'; // 四级佣金
|
||||
// $fivePrice = '0.00'; // 五级佣金
|
||||
// $sixPrice = '0.00'; // 六级佣金
|
||||
|
||||
// $supplyTeamLevelOne = ['rate' => 0];
|
||||
// $supplyTeamLevelTwo = ['rate' => 0];
|
||||
// $supplyTeamLevelThree = ['rate' => 0];
|
||||
// $supplyTeamLevelFour = ['rate' => 0];
|
||||
// $supplyTeamLevelFive = ['rate' => 0];
|
||||
// $supplyTeamLevelSix = ['rate' => 0];
|
||||
|
||||
// if($supplyTeamLevelOne)
|
||||
// {
|
||||
// // 一级可获得金额
|
||||
// $onePrice = sprintf("%.2f", $price/100*$supplyTeamLevelOne['rate']);
|
||||
|
||||
// // 分润数据
|
||||
// $dataArrOne = [
|
||||
// 'user_id' => $data['uid'], // 用户ID
|
||||
// 'pay_price' => $data['inc'], // 订单金额
|
||||
// 'order_sn' => $data['order_sn'], // 订单编号
|
||||
// 'supply_sn' => $data['order_sn'], // 订单编号
|
||||
// 'order_id' => $data['order_id'], // 订单ID
|
||||
// 'mer_id' => $data['mer_id'], // 商户ID
|
||||
// 'supply_level_id' => $supplyLevel['id'], // 分佣等级ID
|
||||
// 'brokerage_price' => $onePrice, // 获取的佣金金额
|
||||
// 'user_info' => $user['nickname'], // 用户名
|
||||
// 'fa_supply_chain_id' => $supplyTeam['id'], // 供应链团队ID
|
||||
// ];
|
||||
|
||||
// SupplyChainBorkerage::create($dataArrOne);
|
||||
// }
|
||||
|
||||
// if($supplyTeamLevelTwo)
|
||||
// {
|
||||
// // 二级可获得金额
|
||||
// $twoPrice = sprintf("%.2f", $price/100*$supplyTeamLevelTwo['rate']);
|
||||
// // 分润数据
|
||||
// $dataArrTwo = [
|
||||
// 'user_id' => $data['uid'], // 用户ID
|
||||
// 'pay_price' => $data['inc'], // 订单金额
|
||||
// 'order_sn' => $data['order_sn'], // 订单编号
|
||||
// 'supply_sn' => $data['order_sn'], // 订单编号
|
||||
// 'order_id' => $data['order_id'], // 订单ID
|
||||
// 'mer_id' => $data['mer_id'], // 商户ID
|
||||
// 'supply_level_id' => $supplyLevel['id'], // 分佣等级ID
|
||||
// 'brokerage_price' => $usrPrice, // 获取的佣金金额
|
||||
// 'user_info' => $user['nickname'], // 用户名
|
||||
// 'fa_supply_chain_id' => $supplyTeam['id'], // 供应链团队ID
|
||||
// ];
|
||||
|
||||
// SupplyChainBorkerage::create($dataArrTwo);
|
||||
// }
|
||||
|
||||
// if($supplyTeamLevelThree)
|
||||
// {
|
||||
// // 三级可获得金额
|
||||
// $threePrice = sprintf("%.2f", $price/100*$supplyTeamLevelThree['rate']);
|
||||
// // 分润数据
|
||||
// $dataArrThree = [
|
||||
// 'user_id' => $data['uid'], // 用户ID
|
||||
// 'pay_price' => $data['inc'], // 订单金额
|
||||
// 'order_sn' => $data['order_sn'], // 订单编号
|
||||
// 'supply_sn' => $data['order_sn'], // 订单编号
|
||||
// 'order_id' => $data['order_id'], // 订单ID
|
||||
// 'mer_id' => $data['mer_id'], // 商户ID
|
||||
// 'supply_level_id' => $supplyLevel['id'], // 分佣等级ID
|
||||
// 'brokerage_price' => $usrPrice, // 获取的佣金金额
|
||||
// 'user_info' => $user['nickname'], // 用户名
|
||||
// 'fa_supply_chain_id' => $supplyTeam['id'], // 供应链团队ID
|
||||
// ];
|
||||
|
||||
// SupplyChainBorkerage::create($dataArrThree);
|
||||
// }
|
||||
|
||||
// if($supplyTeamLevelFour)
|
||||
// {
|
||||
// // 四级可获得金额
|
||||
// $fourPrice = sprintf("%.2f", $price/100*$supplyTeamLevelFour['rate']);
|
||||
// // 分润数据
|
||||
// $dataArrFour = [
|
||||
// 'user_id' => $data['uid'], // 用户ID
|
||||
// 'pay_price' => $data['inc'], // 订单金额
|
||||
// 'order_sn' => $data['order_sn'], // 订单编号
|
||||
// 'supply_sn' => $data['order_sn'], // 订单编号
|
||||
// 'order_id' => $data['order_id'], // 订单ID
|
||||
// 'mer_id' => $data['mer_id'], // 商户ID
|
||||
// 'supply_level_id' => $supplyLevel['id'], // 分佣等级ID
|
||||
// 'brokerage_price' => $usrPrice, // 获取的佣金金额
|
||||
// 'user_info' => $user['nickname'], // 用户名
|
||||
// 'fa_supply_chain_id' => $supplyTeam['id'], // 供应链团队ID
|
||||
// ];
|
||||
|
||||
// SupplyChainBorkerage::create($dataArrFour);
|
||||
// }
|
||||
|
||||
// if($supplyTeamLevelFive)
|
||||
// {
|
||||
// // 五级可获得金额
|
||||
// $fivePrice = sprintf("%.2f", $price/100*$supplyTeamLevelFive['rate']);
|
||||
// // 分润数据
|
||||
// $dataArrFive = [
|
||||
// 'user_id' => $data['uid'], // 用户ID
|
||||
// 'pay_price' => $data['inc'], // 订单金额
|
||||
// 'order_sn' => $data['order_sn'], // 订单编号
|
||||
// 'supply_sn' => $data['order_sn'], // 订单编号
|
||||
// 'order_id' => $data['order_id'], // 订单ID
|
||||
// 'mer_id' => $data['mer_id'], // 商户ID
|
||||
// 'supply_level_id' => $supplyLevel['id'], // 分佣等级ID
|
||||
// 'brokerage_price' => $fivePrice, // 获取的佣金金额
|
||||
// 'user_info' => $user['nickname'], // 用户名
|
||||
// 'fa_supply_chain_id' => $supplyTeam['id'], // 供应链团队ID
|
||||
// ];
|
||||
|
||||
// SupplyChainBorkerage::create($dataArrFive);
|
||||
// }
|
||||
|
||||
// if($supplyTeamLevelSix)
|
||||
// {
|
||||
// // 六级可获得金额
|
||||
// $sixPrice = sprintf("%.2f", $price/100*$supplyTeamLevelSix['rate']);
|
||||
// // 分润数据
|
||||
// $dataArrSix = [
|
||||
// 'user_id' => $data['uid'], // 用户ID
|
||||
// 'pay_price' => $data['inc'], // 订单金额
|
||||
// 'order_sn' => $data['order_sn'], // 订单编号
|
||||
// 'supply_sn' => $data['order_sn'], // 订单编号
|
||||
// 'order_id' => $data['order_id'], // 订单ID
|
||||
// 'mer_id' => $data['mer_id'], // 商户ID
|
||||
// 'supply_level_id' => $supplyLevel['id'], // 分佣等级ID
|
||||
// 'brokerage_price' => $sixPrice, // 获取的佣金金额
|
||||
// 'user_info' => $user['nickname'], // 用户名
|
||||
// 'fa_supply_chain_id' => $supplyTeam['id'], // 供应链团队ID
|
||||
// ];
|
||||
|
||||
// SupplyChainBorkerage::create($dataArrSix);
|
||||
// }
|
||||
|
||||
\think\facade\Log::record('执行完毕');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::info('小组服务佣金同步失败: ' . var_export($data, 1) . $e->getMessage());
|
||||
|
Loading…
x
Reference in New Issue
Block a user