mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-30 22:40:48 +00:00
优化下单验证
This commit is contained in:
parent
9ee302d53b
commit
91f39ea274
@ -196,10 +196,7 @@ class StoreOrderController
|
||||
if ($bargainId) {
|
||||
$bargainServices->checkBargainUser((int)$bargainId, $uid);
|
||||
}
|
||||
//下单前发票验证
|
||||
if ($invoice_id) {
|
||||
$userInvoiceServices->checkInvoice((int)$invoice_id, $uid);
|
||||
}
|
||||
|
||||
if ($pinkId) {
|
||||
$pinkId = (int)$pinkId;
|
||||
/** @var StorePinkServices $pinkServices */
|
||||
@ -235,7 +232,7 @@ class StoreOrderController
|
||||
}
|
||||
}
|
||||
$virtual_type = $cartGroup['cartInfo'][0]['productInfo']['virtual_type'] ?? 0;
|
||||
$order = $createServices->createOrder($uid, $key, $cartGroup, $request->user()->toArray(), $addressId, $payType, !!$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $shipping_type, $real_name, $phone, $storeId, !!$news, $advanceId, $virtual_type, $customForm);
|
||||
$order = $createServices->createOrder($uid, $key, $cartGroup, $request->user()->toArray(), $addressId, $payType, !!$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $shipping_type, $real_name, $phone, $storeId, !!$news, $advanceId, $virtual_type, $customForm, $invoice_id);
|
||||
if ($order === false) {
|
||||
if ($seckill_id || $combinationId || $advanceId || $bargainId) {
|
||||
foreach ($cartInfo as $item) {
|
||||
@ -261,14 +258,8 @@ class StoreOrderController
|
||||
if (!$orderInfo || !isset($orderInfo['paid'])) {
|
||||
return app('json')->fail(410194);
|
||||
}
|
||||
//创建开票数据
|
||||
if ($invoice_id) {
|
||||
$storeOrderInvoiceServices->makeUp($uid, $orderId, (int)$invoice_id);
|
||||
}
|
||||
|
||||
$info = compact('orderId', 'key');
|
||||
|
||||
return app('json')->status('success', 410203, $info);
|
||||
return app('json')->status('success', 410203, compact('orderId', 'key'));
|
||||
|
||||
// if ($orderId) {
|
||||
// switch ($payType) {
|
||||
|
||||
@ -21,6 +21,7 @@ use app\services\product\product\StoreCategoryServices;
|
||||
use app\services\shipping\ShippingTemplatesFreeServices;
|
||||
use app\services\shipping\ShippingTemplatesRegionServices;
|
||||
use app\services\shipping\ShippingTemplatesServices;
|
||||
use app\services\user\UserInvoiceServices;
|
||||
use app\services\wechat\WechatUserServices;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\exceptions\ApiException;
|
||||
@ -137,8 +138,13 @@ class StoreOrderCreateServices extends BaseServices
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function createOrder($uid, $key, $cartGroup, $userInfo, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckillId = 0, $bargainId = 0, $shippingType = 1, $real_name = '', $phone = '', $storeId = 0, $news = false, $advanceId = 0, $virtual_type = 0, $customForm = [])
|
||||
public function createOrder($uid, $key, $cartGroup, $userInfo, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckillId = 0, $bargainId = 0, $shippingType = 1, $real_name = '', $phone = '', $storeId = 0, $news = false, $advanceId = 0, $virtual_type = 0, $customForm = [], $invoice_id = 0)
|
||||
{
|
||||
//下单前发票验证
|
||||
if ($invoice_id) {
|
||||
app()->make(UserInvoiceServices::class)->checkInvoice((int)$invoice_id, $uid);
|
||||
}
|
||||
|
||||
/** @var StoreOrderComputedServices $computedServices */
|
||||
$computedServices = app()->make(StoreOrderComputedServices::class);
|
||||
$priceData = $computedServices->computedOrder($uid, $userInfo, $cartGroup, $addressId, $payType, $useIntegral, $couponId, true, $shippingType);
|
||||
@ -271,6 +277,11 @@ class StoreOrderCreateServices extends BaseServices
|
||||
return $order;
|
||||
});
|
||||
|
||||
//创建开票数据
|
||||
if ($invoice_id) {
|
||||
app()->make(StoreOrderInvoiceServices::class)->makeUp($uid, $order['order_id'], (int)$invoice_id);
|
||||
}
|
||||
|
||||
// 订单创建成功后置事件
|
||||
event('OrderCreateAfterListener', [$order, compact('cartInfo', 'priceData', 'addressId', 'cartIds', 'news'), $uid, $key, $combinationId, $seckillId, $bargainId]);
|
||||
// 推送订单
|
||||
|
||||
@ -68,6 +68,6 @@ class Json
|
||||
$result = $msg;
|
||||
$msg = 'success';
|
||||
}
|
||||
return app('json')->success($msg, compact('status', 'result'));
|
||||
return $this->success($msg, compact('status', 'result'));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user