update 用户首页

This commit is contained in:
chenbo 2024-01-21 11:23:34 +08:00
parent cdd86618df
commit 80e84e0a96
3 changed files with 127 additions and 89 deletions

View File

@ -303,10 +303,8 @@ class UserLogic extends BaseLogic
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]); return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
} }
public static function firstOrderLog($userIds, $orderMoney, $orderNo) public static function firstOrderLog($userId, $orderMoney, $orderNo)
{ {
foreach ($userIds as $userId) { return Db::name('user_invite_first_order_log')->insert(['user_id' => $userId, 'order_money' => $orderMoney, 'order_no' => $orderNo, 'create_time' => time()]);
Db::name('user_invite_first_order_log')->insert(['user_id' => $userId, 'order_money' => $orderMoney, 'order_no' => $orderNo, 'create_time' => time()]);
}
} }
} }

View File

@ -47,100 +47,126 @@ class ShopCallController extends BaseApiController
if (empty($userSelf)) { if (empty($userSelf)) {
return $this->fail('推广人不存在'); return $this->fail('推广人不存在');
} }
$proportion = 0.03;
// 计算分润
UserLogic::userProfit($userSelf, $orderMoney, $proportion, $orderNo);
// 首单金额记录
UserLogic::firstOrderLog($userSelf['id'], $orderMoney, $orderNo);
// 推广人角色 - 小队/小区队长
if (in_array($userSelf['group_id'] , [2, 18])) { if (in_array($userSelf['group_id'] , [2, 18])) {
$type = 1;
//村/社区合伙人
$where = ['group_id' => 3, 'village'=>$userSelf['village']];
$villageUser = UserLogic::getUser($where);
//镇/街道合伙人
$where1 = ['group_id' => 15, 'street'=>$userSelf['street']];
$streetUser = UserLogic::getUser($where1);
// 计算分润
UserLogic::shareProfit($userSelf, $villageUser, $streetUser, $orderMoney, $orderNo);
// 首单金额记录
UserLogic::firstOrderLog([$userSelf['id'], $villageUser['id'], $streetUser['id']], $orderMoney, $orderNo);
$request['user'] = [
['type' => 1, 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
['type' => 2, 'account' => $villageUser['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
['type' => 3, 'account' => $streetUser['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)],
];
$request['order_id'] = $orderId;
$timestamp = time();
$iv1 = substr(md5($this->apiSecret.$timestamp), 5, 16);
$encryptStr = encrypt($request, $this->apiSecret, $iv1);
// 通知商城
$res = ShopRequestLogic::userProfitNotice(['data' => $encryptStr, 'timestamp' => $timestamp]);
} }
// 村/社区合伙人
if ($userSelf['group_id'] == 3) { if ($userSelf['group_id'] == 3) {
// 查下级 小队 $type = 2;
$where = ['group_id' => [2, 18], 'village'=>$userSelf['village']];
$bridgeUser = UserLogic::getUser($where);
//镇/街道合伙人
$where = ['group_id' => 15, 'village'=>$userSelf['village']];
$streetUser = UserLogic::getUser($where);
// 计算分润
UserLogic::shareProfit($bridgeUser, $userSelf, $streetUser, $orderMoney);
// 首单金额记录
UserLogic::firstOrderLog([$userSelf['id'], $bridgeUser['id'], $streetUser['id']], $orderMoney, $orderNo);
$request['user'] = [
['type' => 1, 'account' => $bridgeUser['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
['type' => 2, 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
['type' => 3, 'account' => $streetUser['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)],
];
$request['order_id'] = $orderId;
$timestamp = time();
$iv1 = substr(md5($this->apiSecret.$timestamp), 5, 16);
$encryptStr = encrypt($request, $this->apiSecret, $iv1);
// 通知商城
$res = ShopRequestLogic::userProfitNotice(['data' => $encryptStr, 'timestamp' => $timestamp]);
} }
// 镇/街道合伙人
if ($userSelf['group_id'] == 15) { if ($userSelf['group_id'] == 15) {
// 查下级村 $type = 3;
$where = ['group_id' => 3, 'village'=>$userSelf['village']];
$villageUser = UserLogic::getUser($where);
//和小队
$where = ['group_id' => [2, 18], 'village'=>$userSelf['village']];
$bridgeUser = UserLogic::getUser($where);
// 计算分润
UserLogic::shareProfit($bridgeUser, $villageUser, $userSelf, $orderMoney);
// 首单金额记录
UserLogic::firstOrderLog([$userSelf['id'], $villageUser['id'], $userSelf['id']], $orderMoney, $orderNo);
$request['user'] = [
['type' => 1, 'account' => $bridgeUser['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
['type' => 2, 'account' => $villageUser['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
['type' => 3, 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)],
];
$request['order_id'] = $orderId;
$timestamp = time();
$iv1 = substr(md5($this->apiSecret.$timestamp), 5, 16);
$encryptStr = encrypt($request, $this->apiSecret, $iv1);
// 通知商城
$res = ShopRequestLogic::userProfitNotice(['data' => $encryptStr, 'timestamp' => $timestamp]);
} }
// 通知商城
$request['user'] = [
['type' => $type, 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)]
];
$request['order_id'] = $orderId;
$timestamp = time();
$iv1 = substr(md5($this->apiSecret.$timestamp), 5, 16);
$encryptStr = encrypt($request, $this->apiSecret, $iv1);
$res = ShopRequestLogic::userProfitNotice(['data' => $encryptStr, 'timestamp' => $timestamp]);
return $this->success('成功'); return $this->success('成功');
// 推广人角色 - 小队/小区队长
// if (in_array($userSelf['group_id'] , [2, 18])) {
//
// //村/社区合伙人
// $where = ['group_id' => 3, 'village'=>$userSelf['village']];
// $villageUser = UserLogic::getUser($where);
//
// //镇/街道合伙人
// $where1 = ['group_id' => 15, 'street'=>$userSelf['street']];
// $streetUser = UserLogic::getUser($where1);
//
// // 计算分润
// UserLogic::shareProfit($userSelf, $villageUser, $streetUser, $orderMoney, $orderNo);
//
// // 首单金额记录
// UserLogic::firstOrderLog([$userSelf['id'], $villageUser['id'], $streetUser['id']], $orderMoney, $orderNo);
//
// $request['user'] = [
// ['type' => 1, 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
// ['type' => 2, 'account' => $villageUser['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
// ['type' => 3, 'account' => $streetUser['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)],
// ];
// $request['order_id'] = $orderId;
// $timestamp = time();
// $iv1 = substr(md5($this->apiSecret.$timestamp), 5, 16);
// $encryptStr = encrypt($request, $this->apiSecret, $iv1);
//
// // 通知商城
// $res = ShopRequestLogic::userProfitNotice(['data' => $encryptStr, 'timestamp' => $timestamp]);
// }
//
// // 村/社区合伙人
// if ($userSelf['group_id'] == 3) {
// // 查下级 小队
// $where = ['group_id' => [2, 18], 'village'=>$userSelf['village']];
// $bridgeUser = UserLogic::getUser($where);
//
// //镇/街道合伙人
// $where = ['group_id' => 15, 'village'=>$userSelf['village']];
// $streetUser = UserLogic::getUser($where);
//
// // 计算分润
// UserLogic::shareProfit($bridgeUser, $userSelf, $streetUser, $orderMoney);
//
// // 首单金额记录
// UserLogic::firstOrderLog([$userSelf['id'], $bridgeUser['id'], $streetUser['id']], $orderMoney, $orderNo);
//
// $request['user'] = [
// ['type' => 1, 'account' => $bridgeUser['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
// ['type' => 2, 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
// ['type' => 3, 'account' => $streetUser['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)],
// ];
// $request['order_id'] = $orderId;
// $timestamp = time();
// $iv1 = substr(md5($this->apiSecret.$timestamp), 5, 16);
// $encryptStr = encrypt($request, $this->apiSecret, $iv1);
//
// // 通知商城
// $res = ShopRequestLogic::userProfitNotice(['data' => $encryptStr, 'timestamp' => $timestamp]);
// }
//
// // 镇/街道合伙人
// if ($userSelf['group_id'] == 15) {
// // 查下级村
// $where = ['group_id' => 3, 'village'=>$userSelf['village']];
// $villageUser = UserLogic::getUser($where);
//
// //和小队
// $where = ['group_id' => [2, 18], 'village'=>$userSelf['village']];
// $bridgeUser = UserLogic::getUser($where);
//
// // 计算分润
// UserLogic::shareProfit($bridgeUser, $villageUser, $userSelf, $orderMoney);
//
// // 首单金额记录
// UserLogic::firstOrderLog([$userSelf['id'], $villageUser['id'], $userSelf['id']], $orderMoney, $orderNo);
//
// $request['user'] = [
// ['type' => 1, 'account' => $bridgeUser['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
// ['type' => 2, 'account' => $villageUser['account'], 'user_profit' => bcmul($orderMoney, 0.03, 2)],
// ['type' => 3, 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, 0.01, 2)],
// ];
// $request['order_id'] = $orderId;
// $timestamp = time();
// $iv1 = substr(md5($this->apiSecret.$timestamp), 5, 16);
// $encryptStr = encrypt($request, $this->apiSecret, $iv1);
//
// // 通知商城
// $res = ShopRequestLogic::userProfitNotice(['data' => $encryptStr, 'timestamp' => $timestamp]);
// }
} }
/** /**

View File

@ -317,4 +317,18 @@ class UserController extends BaseApiController
return bcmul(bcmul($userMonthTotalMoney, $rate, 2), 1, 2); return bcmul(bcmul($userMonthTotalMoney, $rate, 2), 1, 2);
} }
} }
public function getFirstOrderLog()
{
$page = $this->request->param('page_no', 1);
$limit = $this->request->param('page_size', 15);
$firstOrderLogList = Db::name('user_invite_first_order_log')->where('user_id', $this->userId)->page($page, $limit)->select();
$data = [
'lists' => $firstOrderLogList,
'count' => Db::name('user_invite_first_order_log')->where('user_id', $this->userId)->count(),
'page_no' => $page,
'page_size' => $limit,
];
return $this->success('成功', $data);
}
} }