Merge branch 'v4.7.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v4.7.0dev

This commit is contained in:
From-wh 2023-02-28 10:01:26 +08:00
commit 685c65493e
4 changed files with 27 additions and 97 deletions

View File

@ -378,6 +378,12 @@ class User extends AuthController
['spread_open', 1]
]);
if (!$id) return app('json')->fail(100100);
if (!$data['real_name']) {
return app('json')->fail(410245);
}
if (!$data['phone']) {
return app('json')->fail(410245);
}
if ($data['phone']) {
if (!preg_match("/^1[3456789]\d{9}$/", $data['phone'])) return app('json')->fail(400252);
}

View File

@ -154,8 +154,8 @@ class StoreOrderController
* @param StoreOrderInvoiceServices $storeOrderInvoiceServices
* @param StoreCombinationServices $combinationServices
* @param $key
* @return \think\Response
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
@ -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,95 +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);
// if ($orderId) {
// switch ($payType) {
// case PayServices::WEIXIN_PAY:
// if ($orderInfo['paid']) return app('json')->fail(410174);
// //支付金额为0
// if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
// //创建订单jspay支付
// /** @var StoreOrderSuccessServices $success */
// $success = app()->make(StoreOrderSuccessServices::class);
// $payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, PayServices::WEIXIN_PAY);
// if ($payPriceStatus)//0元支付成功
// return app('json')->status('success', 410195, $info);
// else
// return app('json')->status('pay_error');
// } else {
// /** @var OrderPayServices $payServices */
// $payServices = app()->make(OrderPayServices::class);
// if ($from == 'app' && $request->isApp()) {
// $from = 'weixin';
// }
// $info['jsConfig'] = $payServices->orderPay($orderInfo, $from);
// if ($from == 'weixinh5') {
// return app('json')->status('wechat_h5_pay', 410203, $info);
// } else {
// return app('json')->status('wechat_pay', 410203, $info);
// }
// }
// case PayServices::YUE_PAY:
// /** @var YuePayServices $yueServices */
// $yueServices = app()->make(YuePayServices::class);
// $pay = $yueServices->yueOrderPay($orderInfo, $uid);
// if ($pay['status'] === true)
// return app('json')->status('success', 410197, $info);
// else {
// if (is_array($pay))
// return app('json')->status($pay['status'], $pay['msg'], $info);
// else
// return app('json')->status('pay_error', $pay);
// }
// case PayServices::ALIAPY_PAY:
// if (!$quitUrl && ($request->isH5() || $request->isWechat())) {
// return app('json')->status('pay_error', 410198, $info);
// }
// [$url, $param] = explode('?', $quitUrl);
// $quitUrl = $url . '?order_id=' . $orderInfo['order_id'];
// //支付金额为0
// if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
// //创建订单jspay支付
// /** @var StoreOrderSuccessServices $success */
// $success = app()->make(StoreOrderSuccessServices::class);
// $payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, PayServices::ALIAPY_PAY);
// if ($payPriceStatus)//0元支付成功
// return app('json')->status('success', 410199, $info);
// else
// return app('json')->status('pay_error');
// } else {
// /** @var OrderPayServices $payServices */
// $payServices = app()->make(OrderPayServices::class);
// $info['jsConfig'] = $payServices->alipayOrder($orderInfo, $quitUrl, $from == 'routine');
// $payKey = md5($orderInfo['order_id']);
// CacheService::set($payKey, ['order_id' => $orderInfo['order_id'], 'other_pay_type' => false], 300);
// $info['pay_key'] = $payKey;
// return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410203, $info);
// }
// case PayServices::OFFLINE_PAY:
// case 'pc':
// case 'friend':
// return app('json')->status('success', 410203, $info);
// case PayServices::ALLIN_PAY:
// /** @var OrderPayServices $payServices */
// $payServices = app()->make(OrderPayServices::class);
// $info['jsConfig'] = $payServices->orderPay($orderInfo, $payType, [
// 'returl' => sys_config('site_url') . '/pages/index/index',
// ]);
// if ($request->isWechat()) {
// $info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
// }
// return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410203, $info);
// }
// } else return app('json')->fail(410200);
return app('json')->status('success', 410203, compact('orderId', 'key'));
}
/**

View File

@ -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;
@ -131,14 +132,22 @@ class StoreOrderCreateServices extends BaseServices
* @param string $phone
* @param int $storeId
* @param bool $news
* @param int $advanceId
* @param int $virtual_type
* @param array $customForm
* @param int $invoice_id
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\db\exception\DataNotFoundException
* @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 +280,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]);
// 推送订单

View File

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