diff --git a/app/common/dao/store/order/StoreOrderDao.php b/app/common/dao/store/order/StoreOrderDao.php index 3e939a47..eddff786 100644 --- a/app/common/dao/store/order/StoreOrderDao.php +++ b/app/common/dao/store/order/StoreOrderDao.php @@ -91,6 +91,9 @@ class StoreOrderDao extends BaseDao ->when(isset($where['activity_type']) && $where['activity_type'] != '', function ($query) use ($where) { $query->where('activity_type', $where['activity_type']); }) + ->when(isset($where['product_type']) && $where['product_type'] != 0, function ($query) use ($where) { + $query->where('is_virtual', $where['product_type']); + }) ->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) { switch ($where['status']) { case 0 : diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 09d29bd2..4d652f22 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -83,7 +83,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository } if ($cart['product_type'] > 0) $order_type = $cart['product_type']; - if ($cart['product_type'] > 0 && (($cart['product_type'] != 10 && count($merchantCart['list']) != 1) || count($merchantCartList) != 1)) { + if ($cart['product_type']<98 &&$cart['product_type'] > 0 && (($cart['product_type'] != 10 && count($merchantCart['list']) != 1) || count($merchantCartList) != 1)) { throw new ValidateException('活动商品必须单独购买'); } if ($cart['product']['type'] && (count($merchantCart['list']) != 1 || count($merchantCartList) != 1)) { @@ -896,7 +896,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository ) + ['allow_address' => !$allow_no_address, 'order_delivery_status' => $orderDeliveryStatus]; } - public function v2CreateOrder(int $pay_type, $user, array $cartId, array $extend, array $mark, array $receipt_data, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, array $post, $source) + public function v2CreateOrder(int $pay_type, $user, array $cartId, array $extend, array $mark, array $receipt_data, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, array $post, $source,int $product_type=0) { $uid = $user->uid; $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true); @@ -920,7 +920,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository $extend = []; } $orderType = $orderInfo['order_type']; - if ($orderType && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) { + + if ($orderType && $orderType< 98 && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) { throw new ValidateException('活动商品请单独购买'); } @@ -972,7 +973,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository $cartIds = []; $orderList = []; $user_address = isset($address) ? ($address['province'] . $address['city'] . $address['district'] . $address['street'] . $address['detail']) : ''; - // 验证下单来源,如果是普通来源,则执行分销推广佣金分配 if($source == 2) // 普通商品 { @@ -1093,13 +1093,17 @@ class StoreOrderCreateRepository extends StoreOrderRepository $rate = bcmul($merchantCart['merchantCategory']['commission_rate'], 100, 4); } + $is_virtual=$order_model ? 1 : 0; + if ($product_type!=0){ + $is_virtual=$product_type; + } //整理订单数据 $_order = [ 'cartInfo' => $merchantCart, 'activity_type' => $orderInfo['order_type'], 'commission_rate' => (float)$rate, 'order_type' => $merchantCart['order']['isTake'] ? 1 : 0, - 'is_virtual' => $order_model ? 1 : 0, + 'is_virtual' => $is_virtual, 'extension_one' => $total_extension_one, 'extension_two' => $total_extension_two, 'order_sn' => $this->getNewOrderId() . ($k + 1), diff --git a/app/controller/api/server/StoreOrder.php b/app/controller/api/server/StoreOrder.php index 70ef813f..d2e71c13 100644 --- a/app/controller/api/server/StoreOrder.php +++ b/app/controller/api/server/StoreOrder.php @@ -67,6 +67,10 @@ class StoreOrder extends BaseController { [$page, $limit] = $this->getPage(); $where['status'] = $this->request->param('status'); + $where['product_type'] = $this->request->param('product_type',0); + if ($where['product_type']==0){ + unset($where['product_type']); + } $where['is_verify'] = $this->request->param('is_verify'); $where['search'] = $this->request->param('store_name'); $where['mer_id'] = $merId; diff --git a/app/controller/api/store/order/StoreCart.php b/app/controller/api/store/order/StoreCart.php index 20c43141..1ec93c24 100644 --- a/app/controller/api/store/order/StoreCart.php +++ b/app/controller/api/store/order/StoreCart.php @@ -74,7 +74,7 @@ class StoreCart extends BaseController switch ($data['product_type']) { case 0: //普通商品 - case 98: //普通商品 + case 98: //供应链商品 $result = app()->make(ProductRepository::class)->cartCheck($data,$this->request->userInfo()); [$source, $sourceId, $pid] = explode(':', $this->request->param('source', '0'), 3) + ['', '', '']; $data['source'] = (in_array($source, [0, 1]) && $pid == $data['product_id']) ? $source : 0; diff --git a/app/controller/api/store/order/StoreMicropayOrder.php b/app/controller/api/store/order/StoreMicropayOrder.php index 6c3dd4bc..65172fa9 100644 --- a/app/controller/api/store/order/StoreMicropayOrder.php +++ b/app/controller/api/store/order/StoreMicropayOrder.php @@ -91,7 +91,7 @@ class StoreMicropayOrder extends BaseController } $product=Db::name('store_product')->where('product_id',$find['product_id'])->find(); event('user.cart', compact('user','storeCart')); - return app('json')->success(['product'=>$product,'product_attr' => $cart]); + return app('json')->success(['product'=>$product,'attrValue' => $cart]); } public function v2CreateOrder(StoreCartRepository $cartRepository, StoreOrderCreateRepository $orderCreateRepository) diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 824194a2..cb3390ce 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -93,6 +93,7 @@ class StoreOrder extends BaseController $is_dg = $this->request->param('is_dg',0); $source = $this->request->param('source'); // 1 小组服务 2 普通来源 $source = !isset($source)?2:$source; // 默认来源为2 普通商品订单 + $product_type=$this->request->param('product_type',0); // 98 供应链商品 0 普通商品 100 扫码枪支付 $isPc = $payType === 'pc'; if ($isPc) { $payType = 'balance'; @@ -121,8 +122,8 @@ class StoreOrder extends BaseController // if (!$addressId) // return app('json')->fail('请选择地址'); - $groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post,$source) { - return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post,$source); + $groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post,$source,$product_type) { + return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post,$source,$product_type); }); if ($groupOrder['pay_price'] == 0) { @@ -151,6 +152,7 @@ class StoreOrder extends BaseController { [$page, $limit] = $this->getPage(); $where['status'] = $this->request->param('status'); + $where['product_type'] = $this->request->param('product_type',0); $where['search'] = $this->request->param('store_name'); $source = $this->request->param('source'); $source = !isset($source)?2:$source; // 默认来源为2 普通商品订单 diff --git a/app/controller/api/store/product/StoreMicro.php b/app/controller/api/store/product/StoreMicro.php new file mode 100644 index 00000000..a6d68864 --- /dev/null +++ b/app/controller/api/store/product/StoreMicro.php @@ -0,0 +1,54 @@ +request->userInfo(); + $mer_id =Db::name('store_service')->where('uid',$user['uid'])->where('status',1)->value('mer_id'); + $find=Db::name('store_product')->where('mer_id',$mer_id)->where('bar_code',$code)->find(); + if (!$find){ + $store_product=Db::name('store_product')->where('product_type',98)->where('bar_code',$code)->find(); + if (!$store_product){ + return app('json')->fail('平台没有该条形码,请自行录入'); + } + }; + return app('json')->success(['data'=>$find]); + } + + public function eadtProduct(){ + $product_id = $this->request->param('id', 0); + if ($product_id==0) return app('json')->fail('商品id不能为空'); + $price = $this->request->param('price', 0); + if ($price==0) return app('json')->fail('价格不能为空'); + $stock = $this->request->param('stock', 0); + if ($stock==0) return app('json')->fail('库存不能为空'); + $user = $this->request->userInfo(); + $mer_id =Db::name('store_service')->where('uid',$user['uid'])->where('status',1)->value('mer_id'); + if ($mer_id==0) return app('json')->fail('商户id不能为空'); + $data = [ + 'price'=>$price, + 'stock'=>$stock, + ]; + Db::startTrans(); + try { + Db::name('store_product')->where('mer_id',$mer_id)->where('product_id',$product_id)->update($data); + Db::name('store_product_attr_value')->where('mer_id',$mer_id)->where('product_id',$product_id)->update($data); + // 提交事务 + Db::commit(); + return app('json')->success(['data'=>'','msg'=>'更新成功']); + + } catch (\Exception $e) { + // 回滚事务 + Db::rollback(); + return app('json')->fail($e->getMessage()); + } + Db::transaction(function () use ($mer_id,$product_id,$data) { + + }); + + } +} \ No newline at end of file diff --git a/route/api.php b/route/api.php index 65858c09..191bfc87 100644 --- a/route/api.php +++ b/route/api.php @@ -23,6 +23,12 @@ Route::group('api/', function () { Route::any('test', 'api.Auth/test'); //强制登录 Route::group(function () { + + Route::group('micro', function () { + Route::get('seach_bar_code', '/seach_bar_code'); + Route::post('eadt_product', '/eadtProduct'); + })->prefix('api.store.product.StoreMicro'); + Route::group('v2', function () { //新的下单接口,支持分账 Route::group('order', function () {