增加:配送商缴费订单记录及分配相关接口
This commit is contained in:
parent
afedf06e01
commit
5d3a8f685f
|
|
@ -18,27 +18,40 @@ class AgentDeliveryDao extends BaseDao{
|
|||
* @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']);
|
||||
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['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['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['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']);
|
||||
->when(isset($params['order_id']) && $params['order_id'] !== '',function($query) use ($params){
|
||||
$query->where('order_id',$params['order_id']);
|
||||
})
|
||||
->when(isset($params['is_bind']) && $params['is_bind'] !== '',function($query) use ($params){
|
||||
// 判断:缴费记录是否绑定商户
|
||||
$query->where('mer_id', $params['is_bind'] == 'bind' ? '>' : '<=' , 0);
|
||||
})
|
||||
->with([
|
||||
'agent',
|
||||
'mer' => function($query){
|
||||
'agent' => function($query){
|
||||
$query->field('id,uid,contact_name,contact_phone')
|
||||
->with([
|
||||
'user' => function($query){
|
||||
$query->field('uid,nickname,avatar,phone')->bind(['nickname','avatar','phone']);
|
||||
}
|
||||
]);
|
||||
},
|
||||
'mer' => function($query){
|
||||
$query->field('mer_id,mer_name,mer_avatar');
|
||||
},
|
||||
'store_order' => function($query){
|
||||
$query->field('order_id,order_sn,pay_price,group_order_id,status');
|
||||
},
|
||||
])
|
||||
->order('create_time DESC,id DESC');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace app\common\model\marketing\agent;
|
|||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\marketing\Agent;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
|
||||
class AgentDelivery extends BaseModel{
|
||||
|
|
@ -20,14 +21,16 @@ class AgentDelivery extends BaseModel{
|
|||
|
||||
|
||||
public function agent(){
|
||||
return $this->hasOne(Agent::class, 'agent_id', 'id');
|
||||
return $this->hasOne(Agent::class, 'id', 'agent_id');
|
||||
}
|
||||
|
||||
public function mer(){
|
||||
return $this->hasOne(Merchant::class, 'mer_id', 'mer_id');
|
||||
}
|
||||
|
||||
|
||||
public function storeOrder(){
|
||||
return $this->hasOne(StoreOrder::class, 'order_id', 'order_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ use app\common\repositories\BaseRepository;
|
|||
use app\common\repositories\marketing\AgentRepository;
|
||||
use app\common\repositories\store\order\StoreOrderCreateRepository;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use app\common\repositories\system\merchant\MerchantQuotaRecordRepository;
|
||||
use crmeb\services\LockService;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
|
||||
class AgentDeliveryRepository extends BaseRepository{
|
||||
|
|
@ -29,6 +31,25 @@ class AgentDeliveryRepository extends BaseRepository{
|
|||
public function getSearchModel($search){
|
||||
return $this->dao->searchList($search);
|
||||
}
|
||||
/**
|
||||
* Common: 获取配送商缴费记录
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/18 14:25
|
||||
* @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){
|
||||
$query = $this->dao->searchList($params);
|
||||
$count = $query->count();
|
||||
$list = $query->page($page,$limit)->select()->toArray();
|
||||
|
||||
return compact('count','list');
|
||||
}
|
||||
/**
|
||||
* Common: 缴费订单生成
|
||||
* Author: wu-hui
|
||||
|
|
@ -110,6 +131,55 @@ class AgentDeliveryRepository extends BaseRepository{
|
|||
|
||||
return compact('count','list');
|
||||
}
|
||||
/**
|
||||
* Common: 分配订单
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/18 16:53
|
||||
* @param int $merId
|
||||
* @param int $agentDeliveryId
|
||||
* @return mixed
|
||||
*/
|
||||
public function allocationOrder(int $merId,int $agentDeliveryId){
|
||||
// 缴费记录信息
|
||||
$agentDeliveryInfo = $this->getSearchModel(['id'=>$agentDeliveryId])->findOrEmpty()->toArray();
|
||||
if($agentDeliveryInfo['status'] != 1) throw new ValidateException('状态错误,当前订单不可分配!');
|
||||
// 分配操作
|
||||
return Db::transaction(function() use ($merId, $agentDeliveryInfo){
|
||||
$titleQuota = $agentDeliveryInfo['title_quota'] ?? 0;
|
||||
$otherQuota = $agentDeliveryInfo['other_quota'] ?? 0;
|
||||
// 分配额度
|
||||
if($titleQuota > 0){
|
||||
app()->make(MerchantQuotaRecordRepository::class)->changeQuota([
|
||||
'mer_id' => $merId,
|
||||
'change_type' => 1,
|
||||
'quota_type' => 0,
|
||||
'quantity' => $titleQuota,
|
||||
'source' => 3,
|
||||
'order_id' => $agentDeliveryInfo['order_id'],
|
||||
]);
|
||||
}
|
||||
if($otherQuota > 0){
|
||||
app()->make(MerchantQuotaRecordRepository::class)->changeQuota([
|
||||
'mer_id' => $merId,
|
||||
'change_type' => 1,
|
||||
'quota_type' => 1,
|
||||
'quantity' => $otherQuota,
|
||||
'source' => 3,
|
||||
'order_id' => $agentDeliveryInfo['order_id'],
|
||||
]);
|
||||
}
|
||||
// 增加修改
|
||||
AgentDelivery::update([
|
||||
'mer_id' => $merId,
|
||||
'status' => 2
|
||||
],['id' => $agentDeliveryInfo['id']]);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class Delivery extends BaseController{
|
|||
$config = $this->agentRepository->getConfig();
|
||||
$paymentList = $config['payment_list'] ?? [];
|
||||
|
||||
|
||||
return app('json')->success($paymentList);
|
||||
}
|
||||
/**
|
||||
|
|
@ -66,8 +65,28 @@ class Delivery extends BaseController{
|
|||
if($res) return $res;
|
||||
else return app('json')->success("操作成功");
|
||||
}
|
||||
// 缴费记录获取
|
||||
public function paymentRecord(){}
|
||||
/**
|
||||
* Common: 配送商缴费记录
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/18 14:25
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function paymentRecord(){
|
||||
// 参数处理
|
||||
[$page,$limit] = $this->getPage();
|
||||
$params = $this->request->params([
|
||||
['agent_id', 0],
|
||||
'is_bind',
|
||||
'status'
|
||||
]);
|
||||
// 信息列表获取
|
||||
$data = $this->repository->getList((array)$params,(int)$page,(int)$limit);
|
||||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
/**
|
||||
* Common: 获取相关商户
|
||||
* Author: wu-hui
|
||||
|
|
@ -89,11 +108,24 @@ class Delivery extends BaseController{
|
|||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
/**
|
||||
* Common: 分配缴费记录给商户
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/18 16:53
|
||||
* @return mixed
|
||||
*/
|
||||
public function allocationOrder(){
|
||||
// 参数获取
|
||||
$params = $this->request->params([
|
||||
['mer_id', 0],
|
||||
['agent_delivery_id', 0],
|
||||
]);
|
||||
// 分配到订单
|
||||
$this->repository->allocationOrder((int)$params['mer_id'], (int)$params['agent_delivery_id']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return app('json')->success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace app\listener\exchangeQuota;
|
||||
|
||||
use app\common\model\marketing\activity\Record;
|
||||
use app\common\model\marketing\agent\AgentDelivery;
|
||||
use app\common\model\user\ExchangeIntegralRecord;
|
||||
use app\common\model\user\ExchangeQuota;
|
||||
use app\common\model\user\ExchangeQuotaRecord;
|
||||
|
|
@ -64,10 +65,9 @@ class OrderPaySuccessEvent{
|
|||
}
|
||||
else if($groupOrder->activity_type == 38){
|
||||
// 配送商缴费支付成功
|
||||
|
||||
|
||||
|
||||
|
||||
foreach($groupOrder->orderList as $orderInfo){
|
||||
AgentDelivery::update(['status' => 1],['order_id' => (int)$orderInfo->order_id]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
// 其他订单
|
||||
|
|
|
|||
|
|
@ -422,8 +422,8 @@ Route::group('api/', function () {
|
|||
Route::get('delivery/payment_list', 'Delivery/paymentList');// 获取支付项列表
|
||||
Route::post('delivery/create_order', 'Delivery/createOrder');// 生成支付订单
|
||||
Route::get('delivery/payment_record', 'Delivery/paymentRecord');// 缴费记录
|
||||
|
||||
Route::get('delivery/mer_list', 'Delivery/merList');// 绑定商户
|
||||
Route::post('delivery/allocation_order', 'Delivery/allocationOrder');// 分配缴费记录
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue