完善供应链采购分佣
This commit is contained in:
parent
e50bb2ed63
commit
ae6481d272
31
app/common/model/store/GeoArea.php
Normal file
31
app/common/model/store/GeoArea.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class GeoArea extends BaseModel
|
||||
{
|
||||
|
||||
public static function tablePk(): ?string
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
public static function tableName(): string
|
||||
{
|
||||
return 'geo_area';
|
||||
}
|
||||
|
||||
}
|
@ -48,6 +48,6 @@ class SupplyChainTeam extends BaseModel
|
||||
|
||||
public function level()
|
||||
{
|
||||
return $this->hasOne(SupplyChainLevel::class, 'id', 'fa_supply_team_id');
|
||||
return $this->hasOne(SupplyChainLevel::class, 'id', 'supply_level_id');
|
||||
}
|
||||
}
|
||||
|
52
app/common/model/user/BkUserInfo.php
Normal file
52
app/common/model/user/BkUserInfo.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\user;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* 农科关联用户信息
|
||||
*
|
||||
*/
|
||||
|
||||
class BkUserInfo extends BaseModel
|
||||
{
|
||||
|
||||
// 设置当前模型的数据库连接
|
||||
protected $connection = 'nongke';
|
||||
protected $table = 'fa_szxc_information_usermsg';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @author xaboy
|
||||
* @day 2020-03-30
|
||||
*/
|
||||
public static function tablePk(): string
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @author xaboy
|
||||
* @day 2020-03-30
|
||||
*/
|
||||
public static function tableName(): string
|
||||
{
|
||||
return 'fa_szxc_information_usermsg';
|
||||
}
|
||||
|
||||
}
|
@ -182,6 +182,16 @@ class User extends BaseModel
|
||||
return $this->hasOne(SupplyChainTeam::class, 'fa_supply_team_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 农科用户关联信息
|
||||
*
|
||||
*/
|
||||
public function nkUserMsg()
|
||||
{
|
||||
return $this->hasOne(BkUserInfo::class, 'phone', 'phone');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $spreadUid
|
||||
* @author xaboy
|
||||
|
@ -28,6 +28,9 @@ use crmeb\services\ExpressService;
|
||||
use crmeb\services\LockService;
|
||||
use think\App;
|
||||
use think\exception\ValidateException;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\store\GeoArea;
|
||||
use app\common\model\system\supplychain\SupplyChainTeam;
|
||||
|
||||
/**
|
||||
* Class StoreOrder
|
||||
@ -105,6 +108,7 @@ class StoreOrder extends BaseController
|
||||
}
|
||||
|
||||
$uid = $this->request->uid();
|
||||
|
||||
// if (!($count = count($cartId)) || $count != count($cartRepository->validIntersection($cartId, $uid)))
|
||||
// return app('json')->fail('数据无效');
|
||||
if($is_dg){
|
||||
|
@ -22,6 +22,8 @@ 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;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\store\GeoArea;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -81,9 +83,43 @@ class SupplyChainOrderBrokerAgeJob implements JobInterface
|
||||
|
||||
$userRepository = app()->make(UserRepository::class);
|
||||
|
||||
// 增加
|
||||
// 增加小组服务佣金
|
||||
$userRepository->incSupplyBrokerage($data['uid'], $price);
|
||||
|
||||
// 后台分组用户开始
|
||||
$userInfo = User::with('nkUserMsg')->find($data['uid']); // 当前用户信息
|
||||
$nkUserMsg = $userInfo['nkUserMsg']; // 当前用户关联上级街道、区县等信息
|
||||
// $brigade_id = $nkUserMsg['brigade_id']; // 大队
|
||||
$village_id = $nkUserMsg['village_id']; // 村
|
||||
$street_id = $nkUserMsg['street_id']; //镇
|
||||
$area_id = $nkUserMsg['area_id']; // 区域
|
||||
$city_code = GeoArea::where('area_code', $area_id)->value('city_code'); // 市
|
||||
$supplyChainTeam = SupplyChainTeam::with('level')->whereIn('parent_code', [$village_id, $street_id, $area_id, $city_code])->select(); // 获取关联上级团队
|
||||
|
||||
// 进行分佣
|
||||
foreach ($supplyChainTeam as $v) {
|
||||
|
||||
// 可获得金额
|
||||
$usrPrice = floatval(($price/100)*$v['level']['rate']);
|
||||
|
||||
// 分润数据
|
||||
$dataArr = [
|
||||
'supply_team_id' => $v['id'], // 用户ID
|
||||
'pay_price' => $data['inc'], // 订单金额
|
||||
'price' => $price, // 订单分佣金额
|
||||
'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' => $v['supply_level_id'], // 分佣等级ID
|
||||
'brokerage_price' => $usrPrice, // 获取的佣金金额
|
||||
'fa_supply_chain_id' => $supplyTeam['id'], // 供应链团队ID
|
||||
];
|
||||
|
||||
// 储存小组服务分佣记录
|
||||
SupplyChainBorkerage::create($dataArr);
|
||||
}
|
||||
|
||||
// 增加小组服务佣金明细
|
||||
// $onePrice = '0.00'; // 一级佣金
|
||||
// $twoPrice = '0.00'; // 二级佣金
|
||||
|
Loading…
x
Reference in New Issue
Block a user