parent
1fdb194e56
commit
616204376d
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
namespace app\common\dao\marketing\agent;
|
||||
|
||||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\model\marketing\agent\AgentDelivery;
|
||||
|
||||
class AgentDeliveryDao extends BaseDao{
|
||||
|
||||
protected function getModel(): string{
|
||||
return AgentDelivery::class;
|
||||
}
|
||||
/**
|
||||
* Common: 公共搜索查询
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/17 17:31
|
||||
* @param array $params
|
||||
* @return AgentDelivery
|
||||
*/
|
||||
public function searchList(array $params){
|
||||
return (new AgentDelivery())
|
||||
->when(isset($params['id']) && $params['id'] !== '',function($query) use ($params){
|
||||
$query->where('id', (int)$params['id']);
|
||||
})
|
||||
->when(isset($params['agent_id']) && $params['agent_id'] !== '',function($query) use ($params){
|
||||
$query->where('agent_id', (int)$params['agent_id']);
|
||||
})
|
||||
->when(isset($params['mer_id']) && $params['mer_id'] !== '',function($query) use ($params){
|
||||
$query->where('mer_id', (int)$params['mer_id']);
|
||||
})
|
||||
->when(isset($params['status']) && $params['status'] !== '',function($query) use ($params){
|
||||
$query->where('status', $params['status']);
|
||||
})
|
||||
->when(isset($params['order_id']) && $params['order_id'] !== '',function($query) use ($params){
|
||||
$query->where('order_id', $params['order_id']);
|
||||
})
|
||||
->with([
|
||||
'agent',
|
||||
'mer' => function($query){
|
||||
$query->field('mer_id,mer_name,mer_avatar');
|
||||
},
|
||||
])
|
||||
->order('create_time DESC,id DESC');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
namespace app\common\model\marketing\agent;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\marketing\Agent;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
|
||||
class AgentDelivery extends BaseModel{
|
||||
|
||||
|
||||
public static function tablePk(): string{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
public static function tableName(): string{
|
||||
return 'agent_delivery';
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function agent(){
|
||||
return $this->hasOne(Agent::class, 'agent_id', 'id');
|
||||
}
|
||||
|
||||
public function mer(){
|
||||
return $this->hasOne(Merchant::class, 'mer_id', 'mer_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
namespace app\common\repositories\marketing\agent;
|
||||
|
||||
use app\common\dao\marketing\agent\AgentDeliveryDao;
|
||||
use app\common\model\marketing\agent\AgentDelivery;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\store\order\StoreOrderCreateRepository;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use crmeb\services\LockService;
|
||||
use think\facade\Db;
|
||||
|
||||
class AgentDeliveryRepository extends BaseRepository{
|
||||
|
||||
protected $dao;
|
||||
|
||||
public function __construct(AgentDeliveryDao $dao){
|
||||
$this->dao = $dao;
|
||||
}
|
||||
/**
|
||||
* Common: 公共查询模型
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/17 17:37
|
||||
* @param $search
|
||||
* @return AgentDelivery
|
||||
*/
|
||||
public function getSearchModel($search){
|
||||
return $this->dao->searchList($search);
|
||||
}
|
||||
/**
|
||||
* Common: 缴费订单生成
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/17 18:12
|
||||
* @param $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function createOrder($params){
|
||||
return Db::transaction(function() use ($params){
|
||||
// 支付信息
|
||||
$payInfo = array_intersect_key($params,array_flip((array)["pay_type","return_url","money"]));
|
||||
$payMoney = $params['money'] ?? 0;
|
||||
$userInfo = $params['user_info'] ?? [];
|
||||
// 增加缴费记录
|
||||
$recordId = $this->createPaymentRecord($params);
|
||||
// 判断:是否需要支付
|
||||
if($payMoney > 0){
|
||||
// 订单生成
|
||||
$groupOrder = app()
|
||||
->make(LockService::class)
|
||||
->exec('online_order.create',function() use ($payInfo,$userInfo){
|
||||
$payType = array_search($payInfo['pay_type'],StoreOrderRepository::PAY_TYPE);
|
||||
return app()
|
||||
->make(StoreOrderCreateRepository::class)
|
||||
->onlinePayment($payType,$payInfo,$userInfo, 38);
|
||||
});
|
||||
// 子订单只存在一个 直接查询即可
|
||||
$orderId = app()->make(StoreOrderRepository::class)
|
||||
->getSearch([])
|
||||
->where('group_order_id',$groupOrder->group_order_id)
|
||||
->value('order_id');
|
||||
AgentDelivery::update(['order_id'=>$orderId],['id'=>$recordId]);
|
||||
// 获取支付信息
|
||||
return app()
|
||||
->make(StoreOrderRepository::class)
|
||||
->pay($payInfo['pay_type'],$userInfo,$groupOrder,$payInfo['return_url'],$params['is_app']);
|
||||
}else{
|
||||
AgentDelivery::update(['status'=>1],['id'=>$recordId]);
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Common: 生成缴费记录
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/17 17:50
|
||||
* @param $params
|
||||
* @return int|string
|
||||
*/
|
||||
public function createPaymentRecord($params){
|
||||
return AgentDelivery::insertGetId([
|
||||
'agent_id' => $params['agent_id'] ?? 0,
|
||||
'price' => $params['money'] ?? 0,
|
||||
'title_quota' => $params['title_quota'] ?? 0,
|
||||
'other_quota' => $params['other_quota'] ?? 0,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -181,8 +181,10 @@ class StoreOrderRepository extends BaseRepository
|
|||
$data['title'] = '['.$merName.']进货';
|
||||
$data['mark'] = $user->nickname.'使用商户余额支付' . floatval($groupOrder['pay_price']) . '元';
|
||||
}else if($groupOrder['activity_type'] == 37){
|
||||
$merName = Merchant::where('mer_id',$groupOrder->with_goods_mer_id)->value('mer_name');
|
||||
$data['title'] = '['.$merName.']共创股东加入';
|
||||
$data['title'] = '共创股东加入';
|
||||
$data['mark'] = $user->nickname.'使用余额支付' . floatval($groupOrder['pay_price']) . '元';
|
||||
}else if($groupOrder['activity_type'] == 38){
|
||||
$data['title'] = '配送商缴费';
|
||||
$data['mark'] = $user->nickname.'使用余额支付' . floatval($groupOrder['pay_price']) . '元';
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +290,7 @@ class StoreOrderRepository extends BaseRepository
|
|||
app()->make(ProductAssistSetRepository::class)->changStatus($order->orderProduct[0]['activity_id']);
|
||||
}
|
||||
if ($order->order_type == 1 && $order->status != 10) $order->verify_code = $this->verifyCode();
|
||||
if (!in_array($order->activity_type,[30,31,32,33,34,37]) && $order->orderProduct[0]->product->type == 2) {
|
||||
if (!in_array($order->activity_type,[30,31,32,33,34,37,38]) && $order->orderProduct[0]->product->type == 2) {
|
||||
$order->status = 3;//2; todo 订单进入待评价改为已完成
|
||||
$order->delivery_type = 6;
|
||||
$order->delivery_name = '自动发货';
|
||||
|
|
@ -296,7 +298,7 @@ class StoreOrderRepository extends BaseRepository
|
|||
$isPoints = true;
|
||||
}
|
||||
// 判断:是否为在线买单、酒道馆补差价 在线买单,订单支付则订单完成
|
||||
if(in_array($order->activity_type,[30,31,32,33,34,37])){
|
||||
if(in_array($order->activity_type,[30,31,32,33,34,37,38])){
|
||||
$order->status = 3;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
namespace app\controller\api\marketing\agent;
|
||||
|
||||
|
||||
use app\common\repositories\marketing\agent\AgentDeliveryRepository;
|
||||
use app\common\repositories\marketing\AgentRepository;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\App;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* Common: 运营中心 - 配送商相关
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/17 14:26
|
||||
* Class Delivery
|
||||
* @package app\controller\api\marketing\agent
|
||||
*/
|
||||
class Delivery extends BaseController{
|
||||
|
||||
protected $repository;
|
||||
protected $agentRepository;
|
||||
|
||||
public function __construct(App $app, AgentDeliveryRepository $repository, AgentRepository $agentRepository){
|
||||
parent::__construct($app);
|
||||
$this->repository = $repository;
|
||||
$this->agentRepository = $agentRepository;
|
||||
}
|
||||
/**
|
||||
* Common: 获取缴费列表
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/17 14:25
|
||||
* @return mixed
|
||||
*/
|
||||
public function paymentList(){
|
||||
$config = $this->agentRepository->getConfig();
|
||||
$paymentList = $config['payment_list'] ?? [];
|
||||
|
||||
|
||||
return app('json')->success($paymentList);
|
||||
}
|
||||
/**
|
||||
* Common: 生成缴费记录及订单
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/17 18:12
|
||||
* @return mixed
|
||||
*/
|
||||
public function createOrder(){
|
||||
// 参数获取
|
||||
$params = $this->request->params([
|
||||
['agent_id', 0],
|
||||
['money', 0],
|
||||
['title_quota', 0],
|
||||
['other_quota', 0],
|
||||
// 支付相关
|
||||
'pay_type',
|
||||
'return_url'
|
||||
]);
|
||||
// 参数判断
|
||||
if($params['agent_id'] <= 0) throw new ValidateException('身份信息不明确,请重新登录!');
|
||||
$params['uid'] = $this->request->uid();
|
||||
$params['user_info'] = $this->request->userInfo();
|
||||
$params['is_app'] = $this->request->isApp();
|
||||
$res = $this->repository->createOrder($params);
|
||||
|
||||
if($res) return $res;
|
||||
else return app('json')->success("操作成功");
|
||||
}
|
||||
|
||||
public function paymentRecord(){}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -61,6 +61,13 @@ class OrderPaySuccessEvent{
|
|||
$id = app()->make(MerchantShareholderRepository::class)->getSearch(['order_id'=>(int)$orderInfo->order_id])->value('id');
|
||||
if($id > 0) app()->make(MerchantShareholderRepository::class)->joinSuccess($id);
|
||||
}
|
||||
}
|
||||
else if($groupOrder->activity_type == 38){
|
||||
// 配送商缴费支付成功
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
// 其他订单
|
||||
|
|
|
|||
|
|
@ -401,7 +401,7 @@ Route::group('api/', function () {
|
|||
Route::get('promote_qr_code', 'Merchant/promoteQrCode');// 推广二维码
|
||||
Route::get('online_payment_qr_code', 'Merchant/onlinePaymentQrCode');// 买单二维码
|
||||
})->prefix('api.store.merchant.');
|
||||
// 代理中心相关
|
||||
// 运营中心 - 公共
|
||||
Route::group('agent', function () {
|
||||
Route::get('agent_list', 'agentList');// 我的代理身份列表
|
||||
Route::get('qr_code_invite', 'qrCodeInviteSupplier');// 供应商邀请二维码
|
||||
|
|
@ -415,9 +415,17 @@ Route::group('api/', function () {
|
|||
Route::get('role_and_correlation_role', 'getRoleAndCorrelationRole');// 获取指定角色及相关角色的信息
|
||||
Route::get('my_invite', 'getMyInvite');// 我的邀请(商户)
|
||||
Route::post('update_shareholders', 'updateShareholders');// 修改资源股东
|
||||
|
||||
|
||||
})->prefix('api.Agent/');
|
||||
// 运营中心 - 子类
|
||||
Route::group('agent', function () {
|
||||
// 配送商相关
|
||||
Route::get('delivery/payment_list', 'Delivery/paymentList');// 获取支付项列表
|
||||
Route::post('delivery/create_order', 'Delivery/createOrder');// 生成支付订单
|
||||
Route::get('delivery/payment_record', 'Delivery/paymentRecord');// 缴费记录
|
||||
|
||||
|
||||
|
||||
})->prefix('api.marketing.agent.');
|
||||
// 供应商相关
|
||||
Route::group('supplier', function () {
|
||||
Route::post('apply', 'applyJoin');// 申请成为供应商
|
||||
|
|
|
|||
Loading…
Reference in New Issue