parent
f5381c1878
commit
799cacdac9
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
namespace app\common\dao\common;
|
||||
|
||||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\model\common\PayRecord;
|
||||
|
||||
class PayRecordDao extends BaseDao{
|
||||
|
||||
protected function getModel(): string{
|
||||
return PayRecord::class;
|
||||
}
|
||||
/**
|
||||
* Common: 公共搜索查询
|
||||
* Author: wu-hui
|
||||
* Time: 2024/07/09 16:09
|
||||
* @param array $params
|
||||
* @return PayRecord
|
||||
*/
|
||||
public function searchList(array $params){
|
||||
return (new PayRecord())
|
||||
->when(isset($params['id']) && $params['id'] !== '',function($query) use ($params){
|
||||
$query->where('id', (int)$params['id']);
|
||||
})
|
||||
->when(isset($params['uid']) && $params['uid'] !== '',function($query) use ($params){
|
||||
$query->where('uid', (int)$params['uid']);
|
||||
})
|
||||
->when(isset($params['object_id']) && $params['object_id'] !== '',function($query) use ($params){
|
||||
$query->where('object_id', (int)$params['object_id']);
|
||||
})
|
||||
->when(isset($params['pay_type']) && $params['pay_type'] !== '',function($query) use ($params){
|
||||
if(is_array($params['pay_type'])) $query->whereIn('pay_type', (array)$params['pay_type']);
|
||||
else $query->where('pay_type', (int)$params['pay_type']);
|
||||
})
|
||||
->when(isset($params['pay_status']) && $params['pay_status'] !== '',function($query) use ($params){
|
||||
$query->where('pay_status', (int)$params['pay_status']);
|
||||
})
|
||||
->with([
|
||||
'user' => function($query){
|
||||
$query->field('uid,nickname,real_name,avatar,phone');
|
||||
},
|
||||
'agent' => function($query){
|
||||
$query->field('id,uid,contact_name,contact_phone,agent_type')->append(['agent_type_text']);
|
||||
},
|
||||
])
|
||||
->order('create_time DESC,id DESC');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
namespace app\common\model\common;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\marketing\Agent;
|
||||
use app\common\model\user\User;
|
||||
|
||||
class PayRecord extends BaseModel{
|
||||
|
||||
public static function tablePk(): string{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
public static function tableName(): string{
|
||||
return 'pay_record';
|
||||
}
|
||||
|
||||
|
||||
public function user(){
|
||||
return $this->hasOne(User::class, 'uid', 'uid');
|
||||
}
|
||||
public function agent(){
|
||||
return $this->hasOne(Agent::class, 'id', 'object_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace app\common\repositories\common;
|
||||
|
||||
|
||||
use app\common\dao\common\PayRecordDao;
|
||||
use app\common\repositories\BaseRepository;
|
||||
|
||||
|
||||
class PayRecordRepository extends BaseRepository{
|
||||
|
||||
protected $dao;
|
||||
|
||||
public function __construct(PayRecordDao $dao){
|
||||
$this->dao = $dao;
|
||||
}
|
||||
/**
|
||||
* Common: 公共查询模型
|
||||
* Author: wu-hui
|
||||
* Time: 2024/07/09 16:10
|
||||
* @param $search
|
||||
* @return \app\common\model\common\PayRecord
|
||||
*/
|
||||
public function getSearchModel($search){
|
||||
return $this->dao->searchList($search);
|
||||
}
|
||||
/**
|
||||
* Common: 获取列表信息
|
||||
* Author: wu-hui
|
||||
* Time: 2024/07/09 16:36
|
||||
* @param array $params
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getList(array $params,int $page,int $limit):array{
|
||||
$query = $this->dao->searchList($params);
|
||||
$count = $query->count();
|
||||
$list = $query->page($page,$limit)->select();
|
||||
|
||||
return compact('count','list');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ use app\common\model\marketing\agent\AgentDelivery;
|
|||
use app\common\model\marketing\AgentApply;
|
||||
use app\common\model\user\User;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\common\PayRecordRepository;
|
||||
use app\common\repositories\store\order\StoreOrderCreateRepository;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use app\common\repositories\store\service\StoreServiceRepository;
|
||||
|
|
@ -83,6 +84,7 @@ class AgentApplyRepository extends BaseRepository{
|
|||
$applyInfo['mer_images'] = implode(',',$applyInfo['mer_images']);
|
||||
// 支付信息
|
||||
$payInfo = array_intersect_key($params['data'],array_flip((array)["pay_type","return_url"]));
|
||||
$depositIndex = (int)($params['data']['deposit_index'] ?? 0);
|
||||
$payResult = [];
|
||||
// 根据操作类型进行对应的处理
|
||||
if($params['agentApplyId'] > 0){
|
||||
|
|
@ -94,27 +96,21 @@ class AgentApplyRepository extends BaseRepository{
|
|||
}
|
||||
else{
|
||||
// 添加 是否需要支付
|
||||
$payMoney = 0;// 默认 无需支付
|
||||
$config = app()->make(AgentRepository::class)->getConfig();
|
||||
$agentBaseSet = $config['agent_base_set'] ?? [];
|
||||
$currentSet = $agentBaseSet[$applyInfo['agent_type']] ?? [];
|
||||
|
||||
|
||||
|
||||
debug($currentSet);
|
||||
|
||||
|
||||
switch ((int)$applyInfo['agent_type']) {
|
||||
case 2: $payMoney = $config['province_money'] ?? 0;break;
|
||||
case 3: $payMoney = $config['field_staff_money'] ?? 0;break;
|
||||
case 4: $payMoney = $config['internal_staff_money'] ?? 0;break;
|
||||
case 5: $payMoney = $config['operator_money'] ?? 0;break;
|
||||
case 6: $payMoney = $config['partner_money'] ?? 0;break;
|
||||
case 7: $payMoney = $config['mer_money'] ?? 0;break;
|
||||
case 8: $payMoney = $config['delivery_money'] ?? 0;break;
|
||||
case 9: $payMoney = $config['field_personnel_money'] ?? 0;break;
|
||||
case 10: $payMoney = $config['external_personnel_money'] ?? 0;break;
|
||||
$currentSet = (array)($agentBaseSet[$applyInfo['agent_type']] ?? []);
|
||||
$depositList = (array)($currentSet['deposit_list'] ?? []);
|
||||
$payMoney = (float)($currentSet['total_money'] ?? 0);
|
||||
$surplusPrice = 0;
|
||||
$earnestMoney = (float)($currentSet['earnest_money'] ?? 0);
|
||||
if($payMoney > 0 && $depositIndex != -1 && count($depositList) > 0){
|
||||
$currentDeposit = (array)($depositList[$depositIndex] ?? []);
|
||||
$payMoney = (float)($currentDeposit['deposit_price'] ?? 0);
|
||||
$surplusPrice = (float)($currentDeposit['surplus_price'] ?? 0);
|
||||
}
|
||||
$applyInfo['deposit_price'] = $payMoney;// 定金
|
||||
$applyInfo['earnest_money'] = $earnestMoney;// 保证金
|
||||
$applyInfo['surplus_price'] = $surplusPrice;// 尾款
|
||||
// 生成申请信息
|
||||
$applyInfoId = AgentApply::insertGetId($applyInfo);
|
||||
// 判断:是否需要支付 需要支付生成订单并且获取支付信息
|
||||
|
|
@ -252,6 +248,35 @@ class AgentApplyRepository extends BaseRepository{
|
|||
$insertInfo = array_intersect_key($applyInfo, $keys);
|
||||
$insertInfo['apply_id'] = $applyInfo['id'];
|
||||
$agentId = Agent::insertGetId($insertInfo);
|
||||
// 缴费记录
|
||||
$payTime = date("Y-m-d h:i:s");
|
||||
app()->make(PayRecordRepository::class)->insertAll([
|
||||
[
|
||||
'uid' => $insertInfo['uid'],
|
||||
'object_id' => $agentId,
|
||||
'money' => $applyInfo['deposit_price'],
|
||||
'pay_type' => 1,
|
||||
'pay_time' => $payTime,
|
||||
'pay_status' => 1
|
||||
],
|
||||
[
|
||||
'uid' => $insertInfo['uid'],
|
||||
'object_id' => $agentId,
|
||||
'money' => $applyInfo['surplus_price'],
|
||||
'pay_type' => 2,
|
||||
'pay_time' => null,
|
||||
'pay_status' => $applyInfo['surplus_price'] > 0 ? 0 : 1
|
||||
],
|
||||
[
|
||||
'uid' => $insertInfo['uid'],
|
||||
'object_id' => $agentId,
|
||||
'money' => $applyInfo['earnest_money'],
|
||||
'pay_type' => 3,
|
||||
'pay_time' => null,
|
||||
'pay_status' => $applyInfo['earnest_money'] > 0 ? 0 : 1
|
||||
],
|
||||
]);
|
||||
|
||||
// 判断:如果是餐厅 生成商户信息
|
||||
if((int)$insertInfo['agent_type'] == 7){
|
||||
$password = substr($applyInfo['contact_phone'],-6);
|
||||
|
|
|
|||
|
|
@ -364,6 +364,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '省公司发起人',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
@ -375,6 +376,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '省公司外勤',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
@ -387,6 +389,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '省公司内勤',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
@ -399,6 +402,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '区县运营商',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
@ -412,6 +416,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '区县合伙人',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
@ -426,6 +431,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '餐厅',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
@ -441,6 +447,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '配送商',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
@ -458,6 +465,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '总部外勤',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
@ -468,6 +476,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '总部内勤',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
@ -478,6 +487,7 @@ class AgentRepository extends BaseRepository{
|
|||
'title' => '烟酒店代销商',
|
||||
'is_examine' => 0,
|
||||
'total_money' => '',
|
||||
'earnest_money' => '',
|
||||
'deposit_list' => [],
|
||||
'commission_list' => [
|
||||
'platform' => '',// 平台奖励
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
namespace app\controller\admin\marketing;
|
||||
|
||||
|
||||
use app\common\repositories\common\PayRecordRepository;
|
||||
use app\common\repositories\marketing\AgentApplyRepository;
|
||||
use app\common\repositories\marketing\AgentBrokerageRepository;
|
||||
use app\common\repositories\marketing\AgentRepository;
|
||||
|
|
@ -403,4 +404,24 @@ class Agent extends BaseController{
|
|||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
/**
|
||||
* Common: 获取缴费记录
|
||||
* Author: wu-hui
|
||||
* Time: 2024/07/09 16:38
|
||||
* @return mixed
|
||||
*/
|
||||
public function payRecord(){
|
||||
[$page, $limit] = $this->getPage();
|
||||
$params = $this->request->params([
|
||||
'pay_type',
|
||||
'pay_status',
|
||||
'object_id',
|
||||
]);
|
||||
if($params['pay_type'] == '') $params['pay_type'] = [1,2,3];
|
||||
$data = app()->make(PayRecordRepository::class)->getList((array)$params,(int)$page,(int)$limit);
|
||||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,8 @@ class Agent extends BaseController{
|
|||
['mer_images', []],
|
||||
// 支付相关
|
||||
'pay_type',
|
||||
'return_url'
|
||||
'return_url',
|
||||
'deposit_index'
|
||||
]);
|
||||
$data['uid'] = $this->request->uid();
|
||||
// 信息验证
|
||||
|
|
|
|||
|
|
@ -475,40 +475,48 @@ Route::group(function () {
|
|||
// 代理中心
|
||||
Route::group('marketing/agent', function () {
|
||||
// 代理管理相关
|
||||
Route::get('list','/agentList')->name('systemMarketingAgentList')->option([
|
||||
Route::get('list','agentList')->name('systemMarketingAgentList')->option([
|
||||
'_alias' => '代理列表',
|
||||
]);
|
||||
Route::get('new_list','/newAgentList')->name('systemMarketingNewAgentList')->option([
|
||||
Route::get('new_list','newAgentList')->name('systemMarketingNewAgentList')->option([
|
||||
'_alias' => '代理列表(新)',
|
||||
]);
|
||||
Route::get('children_list','/childrenList')->name('systemMarketingChildrenList')->option([
|
||||
Route::get('children_list','childrenList')->name('systemMarketingChildrenList')->option([
|
||||
'_alias' => '下级代理列表(新)',
|
||||
]);
|
||||
Route::post('edit_info','/editInfo')->name('systemMarketingAgentEditInfo')->option([
|
||||
Route::post('edit_info','editInfo')->name('systemMarketingAgentEditInfo')->option([
|
||||
'_alias' => '代理编辑',
|
||||
]);
|
||||
Route::get('get_edit_info','/getEditInfo')->name('systemMarketingAgentGetEditInfo')->option([
|
||||
Route::get('get_edit_info','getEditInfo')->name('systemMarketingAgentGetEditInfo')->option([
|
||||
'_alias' => '获取编辑信息',
|
||||
]);
|
||||
// 申请审核
|
||||
Route::get('apply_list', '/applyList')->name('systemMarketingAgentApplyList')->option([
|
||||
Route::get('apply_list', 'applyList')->name('systemMarketingAgentApplyList')->option([
|
||||
'_alias' => '代理申请列表',
|
||||
]);
|
||||
Route::post('apply_to_examine', '/toExamine')->name('systemMarketingAgentToExamine')->option([
|
||||
Route::post('apply_to_examine', 'toExamine')->name('systemMarketingAgentToExamine')->option([
|
||||
'_alias' => '代理申请审核',
|
||||
]);
|
||||
// 代理配置相关
|
||||
Route::post('config','/setConfig')->name('systemMarketingAgentSetConfig')->option([
|
||||
Route::post('config','setConfig')->name('systemMarketingAgentSetConfig')->option([
|
||||
'_alias' => '设置配置信息',
|
||||
]);
|
||||
Route::get('config','/getConfig')->name('systemMarketingAgentGetConfig')->option([
|
||||
Route::get('config','getConfig')->name('systemMarketingAgentGetConfig')->option([
|
||||
'_alias' => '获取配置信息',
|
||||
]);
|
||||
// 代理佣金明细
|
||||
Route::get('commission_list','/commissionList')->name('systemMarketingAgentCommissionList')->option([
|
||||
Route::get('commission_list','commissionList')->name('systemMarketingAgentCommissionList')->option([
|
||||
'_alias' => '佣金明细',
|
||||
]);
|
||||
})->prefix('admin.marketing.Agent')->option([
|
||||
// 缴费记录
|
||||
Route::get('commission_list','commissionList')->name('systemMarketingAgentCommissionList')->option([
|
||||
'_alias' => '佣金明细',
|
||||
]);
|
||||
Route::get('pay_record','payRecord')->name('systemMarketingAgentPayRecord')->option([
|
||||
'_alias' => '缴费记录',
|
||||
]);
|
||||
|
||||
})->prefix('admin.marketing.Agent/')->option([
|
||||
'_path' => '/marketing/agent/list',
|
||||
'_auth' => true,
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue