修改小组服务下单,增加source来源

This commit is contained in:
monanxiao 2023-03-10 11:33:32 +08:00
parent 0cc0a82a75
commit 2b936eab29
5 changed files with 23 additions and 7 deletions

View File

@ -895,8 +895,9 @@ 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)
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, int $source)
{
$uid = $user->uid;
$orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true);
$order_model = $orderInfo['order_model'];

View File

@ -25,6 +25,7 @@ use app\common\dao\store\product\SpuDao;
use app\common\repositories\store\StoreCategoryRepository;
use app\common\repositories\store\StoreSeckillActiveRepository;
use app\common\repositories\user\UserVisitRepository;
use app\common\model\system\supplychain\SupplyChainLinkMerchant;
use think\facade\Queue;
class SpuRepository extends BaseRepository
@ -142,12 +143,25 @@ class SpuRepository extends BaseRepository
$query = $this->dao->search($where);
$query->with([
'merchant.supplyChain' => function ($query) {
'merchant' => function ($query) {
$query->field($this->merchantFiled)->with(['type_name']);
},
'issetCoupon'
]);
// 假如是小组服务采购商品,则增加供应链商品的筛选,只获取已入驻商户的商品
if($source == 1)
{
// 获取供应链商户ID
$MerListId = SupplyChainLinkMerchant::with(['supplyChain', 'category'])
->hasWhere('supplyChain', ['status' => 1]) // 启用的供应链团队
->group('eb_merchant_id') // 以分类分组
->column('eb_merchant_id');
// 只获取当前供应链内商户的商品
$query->whereIn('S.mer_id', $MerListId);
}
$productMake = app()->make(ProductRepository::class);
$count = $query->count();
@ -157,6 +171,7 @@ class SpuRepository extends BaseRepository
$append[] = 'max_extension';
$list->append($append);
$list = $this->getBorderList($list);
return compact('count', 'list');
}

View File

@ -68,7 +68,7 @@ class StoreCart extends BaseController
{
$data = $this->checkParams($validate);
if(!in_array($data['product_type'],[0,1,2,3,4])) return app('json')->fail('商品类型错误');
if(!in_array($data['product_type'],[0,1,2,3,4,99])) return app('json')->fail('商品类型错误');
if ($data['cart_num'] <= 0) return app('json')->fail('购买数量有误');
$user = $this->request->userInfo();
event('user.cart.before',compact('user','data'));
@ -103,7 +103,7 @@ class StoreCart extends BaseController
$data['product_id'] = $result['product']['product_id'];
break;
case 99: //小组代购
$result = app()->make(ProductGroupRepository::class)->cartCheck($data,$this->request->userInfo());
$result = app()->make(ProductRepository::class)->cartCheck($data,$this->request->userInfo());
$data['source'] = $data['product_type'];
$data['source_id'] = $data['group_buying_id'];
$data['product_id'] = $result['product']['product_id'];

View File

@ -88,6 +88,7 @@ class StoreOrder extends BaseController
$payType = $this->request->param('pay_type');
$post = (array)$this->request->param('post');
$is_dg = $this->request->param('is_dg',0);
$source = (int)$this->request->param('source'); // 1 小组服务 2 普通来源
$isPc = $payType === 'pc';
if ($isPc) {
$payType = 'balance';
@ -115,8 +116,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) {
return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post);
$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);
});
if ($groupOrder['pay_price'] == 0) {

View File

@ -61,7 +61,6 @@ class StoreSpu extends BaseController
'is_good'
]);
// return json($where);;
$where['is_gift_bag'] = 0;
$where['product_type'] = 0;
$where['order'] = $where['order'] ?: 'star';