diff --git a/app/common/dao/marketing/agent/AgentDeliveryDao.php b/app/common/dao/marketing/agent/AgentDeliveryDao.php new file mode 100644 index 0000000..b3a4b7f --- /dev/null +++ b/app/common/dao/marketing/agent/AgentDeliveryDao.php @@ -0,0 +1,47 @@ +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'); + } + + +} diff --git a/app/common/model/marketing/agent/AgentDelivery.php b/app/common/model/marketing/agent/AgentDelivery.php new file mode 100644 index 0000000..b5f7c88 --- /dev/null +++ b/app/common/model/marketing/agent/AgentDelivery.php @@ -0,0 +1,34 @@ +hasOne(Agent::class, 'agent_id', 'id'); + } + + public function mer(){ + return $this->hasOne(Merchant::class, 'mer_id', 'mer_id'); + } + + + + + +} diff --git a/app/common/repositories/marketing/agent/AgentDeliveryRepository.php b/app/common/repositories/marketing/agent/AgentDeliveryRepository.php new file mode 100644 index 0000000..b0e91f0 --- /dev/null +++ b/app/common/repositories/marketing/agent/AgentDeliveryRepository.php @@ -0,0 +1,90 @@ +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, + ]); + } + + + +} diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 771afc7..2c6787f 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -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; } diff --git a/app/controller/api/marketing/agent/Delivery.php b/app/controller/api/marketing/agent/Delivery.php new file mode 100644 index 0000000..db8cd7d --- /dev/null +++ b/app/controller/api/marketing/agent/Delivery.php @@ -0,0 +1,82 @@ +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(){} + + + + + + + + + + + +} diff --git a/app/listener/exchangeQuota/OrderPaySuccessEvent.php b/app/listener/exchangeQuota/OrderPaySuccessEvent.php index ce84c92..d8f95f7 100644 --- a/app/listener/exchangeQuota/OrderPaySuccessEvent.php +++ b/app/listener/exchangeQuota/OrderPaySuccessEvent.php @@ -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{ // 其他订单 diff --git a/route/api.php b/route/api.php index 8519833..6cf3dcf 100644 --- a/route/api.php +++ b/route/api.php @@ -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');// 申请成为供应商