From 866e77c24cfcb7b05d3c5885d77611a682c9df83 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 3 Nov 2023 18:08:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/order/StoreOrderDao.php | 6 +- .../store/order/StoreOrderRepository.php | 4 +- .../api/store/order/StoreOrderBehalf.php | 111 ++++++++++++++++++ app/event.php | 1 + app/listener/paySuccess.php | 59 ++++++++++ app/listener/paySuccessOrder.php | 18 --- route/api.php | 8 +- 7 files changed, 184 insertions(+), 23 deletions(-) create mode 100644 app/controller/api/store/order/StoreOrderBehalf.php create mode 100644 app/listener/paySuccess.php diff --git a/app/common/dao/store/order/StoreOrderDao.php b/app/common/dao/store/order/StoreOrderDao.php index c3178550..2f2b7b93 100644 --- a/app/common/dao/store/order/StoreOrderDao.php +++ b/app/common/dao/store/order/StoreOrderDao.php @@ -139,7 +139,11 @@ class StoreOrderDao extends BaseDao $query->whereIn('order_id', $where['order_ids']); }) ->when(isset($where['order_id']) && $where['order_id'] !== '', function ($query) use ($where) { - $query->where('order_id', $where['order_id']); + if(is_array($where['order_id'])){ + $query->whereIn('order_id',$where['order_id']); + }else{ + $query->where('order_id', $where['order_id']); + } }) ->when(isset($where['take_order']) && $where['take_order'] != '', function ($query) use ($where) { $query->where('order_type', 1)->whereNotNull('verify_time'); diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 974461c1..0d950d05 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -159,6 +159,7 @@ class StoreOrderRepository extends BaseRepository Db::commit(); }catch (Exception $e) { Db::rollback(); + halt($e); throw new ValidateException('余额支付失败'); } @@ -477,7 +478,8 @@ class StoreOrderRepository extends BaseRepository Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_money', 'inc' => $groupOrder->pay_price]); Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_num', 'inc' => 1]); app()->make(UserBrokerageRepository::class)->incMemberValue($groupOrder->uid, 'member_pay_num', $groupOrder->group_order_id); - // event('order.paySuccess', compact('groupOrder')); + $groupOrder=$groupOrder->toArray(); + event('order.paySuccess', compact('groupOrder')); //店内扫码支付 if (isset($groupOrder['micro_pay']) && $groupOrder['micro_pay'] == 1) { $order = $this->dao->search(['uid' => $groupOrder->uid])->where('group_order_id', $groupOrder->group_order_id)->find(); diff --git a/app/controller/api/store/order/StoreOrderBehalf.php b/app/controller/api/store/order/StoreOrderBehalf.php new file mode 100644 index 00000000..17e81376 --- /dev/null +++ b/app/controller/api/store/order/StoreOrderBehalf.php @@ -0,0 +1,111 @@ + +// +---------------------------------------------------------------------- + + +namespace app\controller\api\store\order; + + +use app\common\model\store\order\StoreGroupOrder; +use app\common\repositories\delivery\DeliveryOrderRepository; +use app\common\repositories\store\order\StoreOrderCreateRepository; +use app\common\repositories\store\order\StoreOrderReceiptRepository; +use app\validate\api\UserReceiptValidate; +use crmeb\basic\BaseController; +use app\common\repositories\store\order\StoreCartRepository; +use app\common\repositories\store\order\StoreGroupOrderRepository; +use app\common\repositories\store\order\StoreOrderRepository; +use app\common\repositories\user\UserAddressRepository; +use think\exception\ValidateException; +use crmeb\services\ExpressService; +use crmeb\services\LockService; +use think\facade\Db; +use think\App; +use think\facade\Log; + +/**代发订单 + * Class StoreOrder + * @package app\controller\api\store\order + * @author xaboy + * @day 2020/6/10 + */ +class StoreOrderBehalf extends BaseController +{ + /** + * @var StoreOrderRepository + */ + protected $repository; + + /** + * StoreOrder constructor. + * @param App $app + * @param StoreOrderRepository $repository + */ + public function __construct(App $app, StoreOrderRepository $repository) + { + parent::__construct($app); + $this->repository = $repository; + } + /** + * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author xaboy + * @day 2020/6/10 + */ + public function lst() + { + [$page, $limit] = $this->getPage(); + $status = $this->request->param('status',1); + + $uid= $this->request->userInfo()['uid']; + $mer_id= Db::name('store_service')->where('uid',$uid)->where('is_del',0)->value('mer_id'); + if($mer_id){ + $column= Db::name('store_order_behalf')->where('mer_id',$mer_id)->where('status',$status)->page($page)->limit($limit)->column('order_id'); + if($column){ + $where['order_id']=$column; + return app('json')->success($this->repository->getList($where, 1, 100)); + + } + } + return app('json')->success([]); + } + + /** + * @param $id + * @return mixed + * @author xaboy + * @day 2020/6/10 + */ + public function detail($id) + { + $order = $this->repository->getDetail((int)$id, $this->request->uid()); + if (!$order) + return app('json')->fail('订单不存在'); + if ($order->order_type == 1) { + $order->append(['take', 'refund_status']); + } + return app('json')->success($order->toArray()); + } + + /** + * @return mixed + * @author xaboy + * @day 2020/6/10 + */ + public function number() + { + $productType = $this->request->param('product_type', 0); + return app('json')->success($this->repository->userOrderNumber($this->request->uid(), $productType)); + } + +} diff --git a/app/event.php b/app/event.php index 67b8ad84..d63961fe 100644 --- a/app/event.php +++ b/app/event.php @@ -66,6 +66,7 @@ return [ 'pay_success_meal' => [\crmeb\listens\pay\MealSuccessListen::class], // 'community_address'=>[\app\listener\CommunityAddress::class], 'order.paySuccessOrder'=>[\app\listener\paySuccessOrder::class], + 'order.paySuccess'=>[\app\listener\paySuccess::class], 'pay_success_margin'=>[\app\listener\paySuccessMargin::class], 'order.sendGoodsCode'=>[\app\listener\SendGoodsCode::class], 'product.create'=>[\app\listener\ProductCreate::class], diff --git a/app/listener/paySuccess.php b/app/listener/paySuccess.php new file mode 100644 index 00000000..d528f5cd --- /dev/null +++ b/app/listener/paySuccess.php @@ -0,0 +1,59 @@ + $order) { + $merchant = Merchant::find($order['mer_id']); + if($merchant['type_id']==13){ + $codes=explode(',',$order['user_address_code']); + if(count($codes)>4){ + $merchant_two= Db::name('merchant')->where('street_id',$codes[3])->where('type_id',17)->where('category_id',$merchant['category_id'])->find(); + if($merchant_two){ + $datas=[ + 'master_mer_id'=>$order['mer_id'], + 'mer_id'=>$merchant_two['mer_id'], + 'order_id'=>$order['order_id'], + 'status'=>1 + ]; + Db::name('store_order_behalf')->insert($datas); + } + + } + } + } + }catch(\Exception $e){ + Log::error($e->getMessage().'lien:'.$e->getLine()); + } + + } +} diff --git a/app/listener/paySuccessOrder.php b/app/listener/paySuccessOrder.php index e6b1d560..808716ae 100644 --- a/app/listener/paySuccessOrder.php +++ b/app/listener/paySuccessOrder.php @@ -41,24 +41,6 @@ class paySuccessOrder if (!$merchant || $merchant['street_id'] == 0) { throw new \Exception('商户地址不存在', 200); } - if($merchant['type_id']==13){ - $codes=explode(',',$event['order']['user_address_code']); - $count_code=count($codes); - if($count_code>4){ - $merchant_two= Db::name('merchant')->where('street_id',$count_code[3])->where('type_id',17)->where('category_id',$merchant['category_id'])->find(); - if($merchant_two){ - $datas=[ - 'master_mer_id'=>$merchant['mer_id'], - 'mer_id'=>$merchant_two['mer_id'], - 'order_id'=>$event['order']['order_id'], - 'status'=>1 - ]; - Db::name('store_order_behalf')->insert($datas); - } - - } - } - $this->streetId = $merchant['street_id']; $commission_rate = ($event['order']['commission_rate'] / 100); diff --git a/route/api.php b/route/api.php index 83ab2f96..ca939186 100644 --- a/route/api.php +++ b/route/api.php @@ -78,7 +78,7 @@ Route::group('api/', function () { Route::post('user/margin', 'api.Auth/doMargin'); Route::get('user/margin/list', 'api.Auth/marginList'); - + Route::post('zhibo/reward', 'api.user.Zhibo/reward'); Route::get('zhibo/rewardList', 'api.user.Zhibo/rewardList'); Route::get('zhibo/rewardAmount', 'api.user.Zhibo/rewardAmount'); @@ -344,6 +344,10 @@ Route::group('api/', function () { Route::post('/confirm', '/confirm'); })->prefix('api.server.StoreOrder')->middleware(\app\common\middleware\MerchantServerMiddleware::class, 0); + //代发货订单 + Route::group('behalf_admin', function () { + Route::get('/order_list', '/lst'); + })->prefix('api.store.order.StoreOrderBehalf'); //管理员申请转账 Route::get('admin/:merId/apply', 'api.store.merchant.Merchant/apply'); Route::post('admin/:merId/create_apply', 'api.store.merchant.Merchant/createApply'); @@ -717,5 +721,3 @@ Route::group('/open-location', function () { Route::miss('View/h5'); })->middleware(InstallMiddleware::class) ->middleware(CheckSiteOpenMiddleware::class); - -