Merge branch 'develop'

This commit is contained in:
monanxiao 2023-03-16 10:57:29 +08:00
commit a20f000909
7 changed files with 137 additions and 2 deletions

View 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';
}
}

View File

@ -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');
}
}

View 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';
}
}

View File

@ -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

View File

@ -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){

View File

@ -102,6 +102,8 @@ class User extends BaseController
'yesterday_brokerage' => $this->yesterdayBrokerage($user['uid'], $source),
'total_extract' => $this->userTotalExtract($user['uid'], $source),
'total_brokerage' => $this->totalBrokerage($user['uid'], $source),
'brokerage_price' => $user['brokerage_price'], // 可提现金额
'broken_day' => (int)systemConfig('lock_brokerage_timer'), //冻结天数
];
return app('json')->success($data);

View File

@ -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'; // 二级佣金