|
|
@@ -11,6 +11,7 @@
|
|
11
|
11
|
namespace app\controller\api\store\order;
|
|
12
|
12
|
|
|
13
|
13
|
|
|
|
14
|
+use app\common\enum\user\UserEnum;
|
|
14
|
15
|
use app\common\model\store\order\StoreRefundOrder;
|
|
15
|
16
|
use app\common\model\system\admin\Log;
|
|
16
|
17
|
use app\common\repositories\merchant\MerchantRepository;
|
|
|
@@ -18,6 +19,7 @@ use app\common\repositories\store\product\ProductAttrValueRepository;
|
|
18
|
19
|
use app\common\repositories\user\UserAddressRepository;
|
|
19
|
20
|
use app\common\repositories\user\UserRepository;
|
|
20
|
21
|
use app\traits\ShouxinyiApiRequest;
|
|
|
22
|
+use app\validate\api\store\order\CreateValidate;
|
|
21
|
23
|
use crmeb\basic\BaseController;
|
|
22
|
24
|
use app\common\repositories\store\order\StoreCartRepository;
|
|
23
|
25
|
use app\common\repositories\store\order\StoreGroupOrderRepository;
|
|
|
@@ -692,16 +694,27 @@ class StoreOrder extends BaseController
|
|
692
|
694
|
}
|
|
693
|
695
|
|
|
694
|
696
|
/**
|
|
695
|
|
- * @param StoreCartRepository $cartRepository
|
|
696
|
|
- * @return mixed
|
|
697
|
|
- * @author xaboy
|
|
698
|
|
- * @day 2020/6/10
|
|
|
697
|
+ * @param CreateValidate $createValidate
|
|
|
698
|
+ * @return false|string|\think\response\Json
|
|
|
699
|
+ * @throws DataNotFoundException
|
|
|
700
|
+ * @throws DbException
|
|
|
701
|
+ * @throws ModelNotFoundException
|
|
|
702
|
+ * @throws \Throwable
|
|
699
|
703
|
*/
|
|
700
|
|
- public function createOrderNew(StoreCartRepository $cartRepository)
|
|
|
704
|
+ public function createOrderNew(CreateValidate $createValidate)
|
|
701
|
705
|
{
|
|
702
|
706
|
// 1、接收参数
|
|
|
707
|
+ $validationResult = $createValidate->validateRequest();
|
|
|
708
|
+ // 如果验证失败,返回错误
|
|
|
709
|
+ if ($validationResult['status'] == 'error') {
|
|
|
710
|
+ return json($validationResult);
|
|
|
711
|
+ }
|
|
|
712
|
+ // 验证通过,继续处理数据
|
|
|
713
|
+ $allParams = $validationResult['data'];
|
|
|
714
|
+
|
|
|
715
|
+
|
|
703
|
716
|
$allParams = input();
|
|
704
|
|
- \think\facade\Log::info("createOrder params" . json_encode($allParams));
|
|
|
717
|
+
|
|
705
|
718
|
$cartId = $allParams['cart_id'] ?? null;
|
|
706
|
719
|
if (is_null($cartId)) {
|
|
707
|
720
|
return app('json')->fail("缺少购物车ID参数!");
|
|
|
@@ -718,6 +731,15 @@ class StoreOrder extends BaseController
|
|
718
|
731
|
$mer_id = $this->request->param('mer_id', '');//分享id
|
|
719
|
732
|
$uid = $this->request->uid();
|
|
720
|
733
|
|
|
|
734
|
+ // 验证用户信息
|
|
|
735
|
+ try {
|
|
|
736
|
+ $userData = Db::name('user')
|
|
|
737
|
+ ->where('uid', $uid)
|
|
|
738
|
+ ->where('is_del', '=', UserEnum::IS_DEL['No']['code'])
|
|
|
739
|
+ ->find();
|
|
|
740
|
+ } catch (\Exception $e) {
|
|
|
741
|
+ return app('json')->fail('获取当前用户信息失败');
|
|
|
742
|
+ }
|
|
721
|
743
|
|
|
722
|
744
|
// 2、加锁,他之前加的锁好像在锁狗屎,毛线都没锁住, 而且为什么要锁用户
|
|
723
|
745
|
// 增加锁,防止同一用户重读点击
|
|
|
@@ -759,27 +781,18 @@ class StoreOrder extends BaseController
|
|
759
|
781
|
$userAddressRepository = app()->make(UserAddressRepository::class);
|
|
760
|
782
|
try {
|
|
761
|
783
|
$addressData = $userAddressRepository->getWhere(['uid' => $uid, 'address_id' => $addressId]);
|
|
762
|
|
- } catch (\Exception $e) {
|
|
763
|
|
- return app('json')->fail('获取用户收货地址失败');
|
|
764
|
|
- }
|
|
765
|
|
- // 如果不是会员专区的商品,则一定要用户完善的收货地址
|
|
766
|
|
- if ($mer_id != 496) {
|
|
767
|
|
- if (!$addressData['city_id']) {
|
|
|
784
|
+ // 如果不是会员专区的商品,则一定要用户完善的收货地址
|
|
|
785
|
+ if (empty($addressData['city_id'] ?? null)) {
|
|
768
|
786
|
return app('json')->fail('请选择正确的收货地址');
|
|
769
|
787
|
}
|
|
770
|
|
- if ($addressData['code_list'] == '') {
|
|
|
788
|
+ if (empty($addressData['code_list'] ?? null)) {
|
|
771
|
789
|
return app('json')->fail('地址需要选择4级地址!请修改地址!');
|
|
772
|
790
|
}
|
|
773
|
|
- }
|
|
774
|
|
-
|
|
775
|
|
- // 判断组合支付逻辑,积分、VR、京豆
|
|
776
|
|
- try {
|
|
777
|
|
- $userData = Db::name("user")
|
|
778
|
|
- ->where("uid", $uid)
|
|
779
|
|
- ->find();
|
|
780
|
791
|
} catch (\Exception $e) {
|
|
781
|
|
- return app('json')->fail('获取当前用户信息失败');
|
|
|
792
|
+ return app('json')->fail('获取用户收货地址失败');
|
|
782
|
793
|
}
|
|
|
794
|
+
|
|
|
795
|
+
|
|
783
|
796
|
$array_fzone_paytype_all = [
|
|
784
|
797
|
'fzone_pay_jingdou' => 0,
|
|
785
|
798
|
'fzone_pay_vr' => 0,
|