调试平台手续费分润退款
This commit is contained in:
parent
f273ebaafa
commit
7d9aaeda1e
@ -15,23 +15,25 @@ namespace app\common\repositories\system\merchant;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\dao\system\merchant\MerchantDao;
|
use app\common\dao\system\merchant\MerchantDao;
|
||||||
|
use app\common\dao\system\serve\ServeOrderDao;
|
||||||
use app\common\model\store\order\StoreOrder;
|
use app\common\model\store\order\StoreOrder;
|
||||||
use app\common\model\store\product\ProductReply;
|
use app\common\model\store\product\ProductReply;
|
||||||
use app\common\model\system\merchant\Merchant;
|
use app\common\model\system\merchant\Merchant;
|
||||||
use app\common\repositories\BaseRepository;
|
use app\common\repositories\BaseRepository;
|
||||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||||
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
||||||
|
use app\common\repositories\store\order\StoreOrderRepository;
|
||||||
use app\common\repositories\store\product\ProductCopyRepository;
|
use app\common\repositories\store\product\ProductCopyRepository;
|
||||||
use app\common\repositories\store\product\ProductRepository;
|
use app\common\repositories\store\product\ProductRepository;
|
||||||
use app\common\repositories\store\product\SpuRepository;
|
use app\common\repositories\store\product\SpuRepository;
|
||||||
use app\common\repositories\store\shipping\ShippingTemplateRepository;
|
use app\common\repositories\store\shipping\ShippingTemplateRepository;
|
||||||
use app\common\repositories\store\StoreCategoryRepository;
|
use app\common\repositories\store\StoreCategoryRepository;
|
||||||
use app\common\repositories\system\attachment\AttachmentRepository;
|
use app\common\repositories\system\attachment\AttachmentRepository;
|
||||||
|
use app\common\repositories\system\serve\ServeOrderRepository;
|
||||||
use app\common\repositories\user\UserBillRepository;
|
use app\common\repositories\user\UserBillRepository;
|
||||||
use app\common\repositories\user\UserRelationRepository;
|
use app\common\repositories\user\UserRelationRepository;
|
||||||
use app\common\repositories\user\UserVisitRepository;
|
use app\common\repositories\user\UserVisitRepository;
|
||||||
use app\common\repositories\wechat\RoutineQrcodeRepository;
|
use app\common\repositories\wechat\RoutineQrcodeRepository;
|
||||||
use crmeb\jobs\AutoMarginJob;
|
|
||||||
use crmeb\jobs\ClearMerchantStoreJob;
|
use crmeb\jobs\ClearMerchantStoreJob;
|
||||||
use crmeb\services\QrcodeService;
|
use crmeb\services\QrcodeService;
|
||||||
use crmeb\services\UploadService;
|
use crmeb\services\UploadService;
|
||||||
@ -691,7 +693,35 @@ class MerchantRepository extends BaseRepository
|
|||||||
'mer_id' => $this->merId,
|
'mer_id' => $this->merId,
|
||||||
'financial_record_sn' => $financeSn . $index
|
'financial_record_sn' => $financeSn . $index
|
||||||
];
|
];
|
||||||
Queue::push(AutoMarginJob::class, ['merId' => $this->merId, 'margin' => $margin, 'orderId' => $order['order_id']]);
|
|
||||||
|
$orderInfo = [
|
||||||
|
'type_id' => $merchant['type_id'],
|
||||||
|
'is_margin' => $merchant['is_margin'],
|
||||||
|
'margin' => $margin,
|
||||||
|
];
|
||||||
|
$values = [
|
||||||
|
'status' => 1,
|
||||||
|
'is_del' => 0,
|
||||||
|
'mer_id' => $merchant['mer_id'],
|
||||||
|
'type' => ServeOrderRepository::TYPE_MARGIN,
|
||||||
|
'meal_id'=> $merchant['type_id'],
|
||||||
|
'pay_type' => ServeOrderRepository::PAY_TYPE_BALANCE,
|
||||||
|
'order_info' => json_encode($orderInfo,JSON_UNESCAPED_UNICODE),
|
||||||
|
'pay_price' => $margin,
|
||||||
|
'store_order_id' => $order['order_id'],
|
||||||
|
];
|
||||||
|
$values['order_sn'] = app()->make(StoreOrderRepository::class)->getNewOrderId('cs');
|
||||||
|
$values['pay_time'] = date('y_m-d H:i:s', time());
|
||||||
|
if (!app()->make(ServeOrderDao::class)->create($values)) {
|
||||||
|
throw new \Exception('serve_order 保存出错');
|
||||||
|
}
|
||||||
|
$merchant->paid_margin = bcadd($margin, $merchant->paid_margin, 2);
|
||||||
|
$merchant->ot_margin = $merchant->paid_margin;
|
||||||
|
$merchant->is_margin = MerchantRepository::PaidMargin;
|
||||||
|
if ($merchant->save() === false) {
|
||||||
|
throw new \Exception('merchant 保存出错');
|
||||||
|
}
|
||||||
|
|
||||||
return [$income, $finance, true];
|
return [$income, $finance, true];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,13 +27,14 @@ class paySuccessOrder
|
|||||||
$this->event = $event;
|
$this->event = $event;
|
||||||
$this->finance = [];
|
$this->finance = [];
|
||||||
$this->index = 1;
|
$this->index = 1;
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
$financialRecordRepository = app()->make(FinancialRecordRepository::class);
|
$financialRecordRepository = app()->make(FinancialRecordRepository::class);
|
||||||
$this->financeSn = $financialRecordRepository->getSn();
|
$this->financeSn = $financialRecordRepository->getSn();
|
||||||
$merchant = Merchant::find($event['order']['mer_id']);
|
$merchant = Merchant::find($event['order']['mer_id']);
|
||||||
|
|
||||||
if (!$merchant || $merchant['street_id'] == 0) {
|
if (!$merchant || $merchant['street_id'] == 0) {
|
||||||
Log::error('商户地址不存在');
|
throw new \Exception('商户地址不存在', 200);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$this->streetId = $merchant['street_id'];
|
$this->streetId = $merchant['street_id'];
|
||||||
|
|
||||||
@ -115,7 +116,18 @@ class paySuccessOrder
|
|||||||
'financial_record_sn' => $this->financeSn . $this->index
|
'financial_record_sn' => $this->financeSn . $this->index
|
||||||
];
|
];
|
||||||
|
|
||||||
$financialRecordRepository->insertAll($this->finance);
|
if (!$financialRecordRepository->insertAll($this->finance)) {
|
||||||
|
throw new \Exception('财务流水保存出错');
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
if ($e->getCode() == 200) {
|
||||||
|
Db::commit();
|
||||||
|
} else {
|
||||||
|
Db::rollback();
|
||||||
|
}
|
||||||
|
Log::error('', ['code' => $e->getCode(), 'message' => $e->getMessage(), 'trace' => $e->getTraceAsString()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calculate($type, $field)
|
public function calculate($type, $field)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user