信用购订单逾期,冻结商户提现,结算后恢复提现
This commit is contained in:
parent
01df202cb7
commit
69c339fc5a
@ -186,4 +186,9 @@ class StoreOrder extends BaseModel
|
|||||||
return $this->hasOne(StoreOrderInterest::class, 'order_id', 'order_id');
|
return $this->hasOne(StoreOrderInterest::class, 'order_id', 'order_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function allowCreditPay()
|
||||||
|
{
|
||||||
|
return $this->pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY && $this->status == self::STATUS_WAIT_PAY;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2486,6 +2486,12 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品',
|
'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品',
|
||||||
'balance' => $user->now_money
|
'balance' => $user->now_money
|
||||||
]);
|
]);
|
||||||
|
$unSettleCount = StoreOrderInterest::where('mer_id', $groupOrder->interest->mer_id)->where('status', 0)->count();
|
||||||
|
if ($unSettleCount === 0) {
|
||||||
|
/** @var MerchantRepository $merchantRepo */
|
||||||
|
$merchantRepo = app()->make(MerchantRepository::class);
|
||||||
|
$merchantRepo->unfreeze($groupOrder->interest->mer_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -743,5 +743,34 @@ class MerchantRepository extends BaseRepository
|
|||||||
return [$income, $finance, true];
|
return [$income, $finance, true];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 冻结商户提现
|
||||||
|
* @param $merchantId
|
||||||
|
* @return void
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function freeze($merchantId)
|
||||||
|
{
|
||||||
|
$merchant = $this->get($merchantId);
|
||||||
|
$merchant->is_fronze = 1;
|
||||||
|
$merchant->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解冻商户提现
|
||||||
|
* @param $merchantId
|
||||||
|
* @return void
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function unfreeze($merchantId)
|
||||||
|
{
|
||||||
|
$merchant = $this->get($merchantId);
|
||||||
|
$merchant->is_fronze = 0;
|
||||||
|
$merchant->save();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,9 @@ class Merchant extends BaseController
|
|||||||
if ($this->userInfo['uid'] != $merchant->uid){
|
if ($this->userInfo['uid'] != $merchant->uid){
|
||||||
return app('json')->fail('你不是管理员无法进行提现操作');
|
return app('json')->fail('你不是管理员无法进行提现操作');
|
||||||
}
|
}
|
||||||
|
if ($merchant->is_frozen){
|
||||||
|
return app('json')->fail('账户被冻结,无法进行提现操作');
|
||||||
|
}
|
||||||
$bankInfo = [
|
$bankInfo = [
|
||||||
'name' => $data['financial_bank_name'],
|
'name' => $data['financial_bank_name'],
|
||||||
'bank' => $data['financial_bank_bank'],
|
'bank' => $data['financial_bank_bank'],
|
||||||
|
@ -240,6 +240,9 @@ class StoreOrder extends BaseController
|
|||||||
if (!$groupOrder)
|
if (!$groupOrder)
|
||||||
return app('json')->fail('订单不存在或已支付');
|
return app('json')->fail('订单不存在或已支付');
|
||||||
$this->repository->changePayType($groupOrder, array_search($type, StoreOrderRepository::PAY_TYPE));
|
$this->repository->changePayType($groupOrder, array_search($type, StoreOrderRepository::PAY_TYPE));
|
||||||
|
if ($groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY && !$groupOrder->orderList[0]->allowCreditPay()) {
|
||||||
|
return app('json')->fail('请等待商家确认订单');
|
||||||
|
}
|
||||||
if ($groupOrder['pay_price'] == 0 || $groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
if ($groupOrder['pay_price'] == 0 || $groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
||||||
$this->repository->paySuccess($groupOrder);
|
$this->repository->paySuccess($groupOrder);
|
||||||
return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
|
return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
|
||||||
|
@ -55,6 +55,7 @@ return [
|
|||||||
\crmeb\listens\AuthCancelActivityListen::class,
|
\crmeb\listens\AuthCancelActivityListen::class,
|
||||||
\crmeb\listens\CloseUserSvipListen::class,
|
\crmeb\listens\CloseUserSvipListen::class,
|
||||||
\crmeb\listens\SendSvipCouponListen::class,
|
\crmeb\listens\SendSvipCouponListen::class,
|
||||||
|
\crmeb\listens\AutoUnfreezeMerchantListen::class,
|
||||||
] : [],
|
] : [],
|
||||||
'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class],
|
'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class],
|
||||||
'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class],
|
'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class],
|
||||||
|
@ -23,6 +23,7 @@ class OrderTake
|
|||||||
$storeOrderInterestRepository = app()->make(StoreOrderInterestRepository::class);
|
$storeOrderInterestRepository = app()->make(StoreOrderInterestRepository::class);
|
||||||
$merchantId = Merchant::where('uid', $order['uid'])->value('mer_id');
|
$merchantId = Merchant::where('uid', $order['uid'])->value('mer_id');
|
||||||
$data = [
|
$data = [
|
||||||
|
'group_order_id' => $order['group_order_id'],
|
||||||
'order_id' => $order['order_id'],
|
'order_id' => $order['order_id'],
|
||||||
'mer_id' => $merchantId,
|
'mer_id' => $merchantId,
|
||||||
'to_mer_id' => $order['mer_id'],
|
'to_mer_id' => $order['mer_id'],
|
||||||
|
35
crmeb/listens/AutoUnfreezeMerchantListen.php
Normal file
35
crmeb/listens/AutoUnfreezeMerchantListen.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
namespace crmeb\listens;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\store\order\StoreOrderInterest;
|
||||||
|
use app\common\repositories\system\merchant\MerchantRepository;
|
||||||
|
use crmeb\interfaces\ListenerInterface;
|
||||||
|
use crmeb\services\TimerService;
|
||||||
|
|
||||||
|
class AutoUnfreezeMerchantListen extends TimerService implements ListenerInterface
|
||||||
|
{
|
||||||
|
public function handle($event): void
|
||||||
|
{
|
||||||
|
$this->tick(1000 * 60, function () {
|
||||||
|
request()->clearCache();
|
||||||
|
$unSettle = StoreOrderInterest::whereTime('start_time', '<=', time())->where('status', 0)->group('mer_id')->column('mer_id');
|
||||||
|
/** @var MerchantRepository $merchantRepo */
|
||||||
|
$merchantRepo = app()->make(MerchantRepository::class);
|
||||||
|
foreach ($unSettle as $merId) {
|
||||||
|
$merchantRepo->freeze($merId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -91,6 +91,7 @@ Route::group('api/', function () {
|
|||||||
Route::post('receipt/:id', '/createReceipt');
|
Route::post('receipt/:id', '/createReceipt');
|
||||||
Route::get('delivery/:id', '/getOrderDelivery');
|
Route::get('delivery/:id', '/getOrderDelivery');
|
||||||
Route::post('settle', '/settle');
|
Route::post('settle', '/settle');
|
||||||
|
Route::post('confirm', '/confirm');
|
||||||
})->prefix('api.store.order.StoreOrder');
|
})->prefix('api.store.order.StoreOrder');
|
||||||
|
|
||||||
// 预售
|
// 预售
|
||||||
|
Loading…
x
Reference in New Issue
Block a user