This commit is contained in:
mkm 2023-11-03 18:08:45 +08:00
parent 5c8954b7ce
commit 866e77c24c
7 changed files with 184 additions and 23 deletions

View File

@ -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');

View File

@ -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();

View File

@ -0,0 +1,111 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
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));
}
}

View File

@ -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],

View File

@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace app\listener;
use app\common\dao\store\order\StoreCartDao;
use app\common\dao\system\merchant\MerchantDao;
use app\common\model\system\merchant\Merchant;
use app\common\repositories\store\order\StoreOrderRepository;
use app\common\repositories\system\merchant\FinancialRecordRepository;
use app\common\repositories\system\merchant\MerchantRepository;
use crmeb\utils\DingTalk;
use think\facade\Db;
use think\facade\Log;
/**
* 支付后逻辑
*/
class paySuccess
{
public $totalAmount;
public $event;
public $finance = [];
public $streetId;
public $financeSn;
public $index = 1;
public $remain;
public function handle($event)
{
try{
$orderList = $event['groupOrder']['orderList'];
foreach ($orderList as $k => $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());
}
}
}

View File

@ -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);

View File

@ -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);