添加:酒道馆进货流程 - 下单及支付流程

This commit is contained in:
wuhui_zzw 2024-03-01 22:04:33 +08:00
parent a94c70a9f5
commit 363a84c7dc
8 changed files with 225 additions and 107 deletions

View File

@ -48,6 +48,17 @@ class StoreCartDao extends BaseDao
->where('is_del', 0)->where('is_fail', 0)->where('is_pay', 0)->where('uid', $uid)->column('cart_id'); ->where('is_del', 0)->where('is_fail', 0)->where('is_pay', 0)->where('uid', $uid)->column('cart_id');
} }
public function ShopValidIntersection(array $ids, $with_goods_mer_id, int $merId = null): array
{
return StoreCart::getDB()->whereIn('cart_id', $ids)
->when($merId, function ($query, $merId) {
$query->where('mer_id', $merId);
})
->where('is_del', 0)->where('is_fail', 0)->where('is_pay', 0)
->where('wine_mer_id', $with_goods_mer_id)
->column('cart_id');
}
/** /**
* @Author:Qinii * @Author:Qinii
* @Date: 2020/6/1 * @Date: 2020/6/1
@ -71,10 +82,14 @@ class StoreCartDao extends BaseDao
return $query; return $query;
} }
public function cartIbByData(array $ids,int $uid,?UserAddress $address,$withGoods = []){
public function cartIbByData(array $ids, int $uid, ?UserAddress $address) return StoreCart::getDb()
{ ->when(isset($withGoods['is_with_goods']) && $withGoods['is_with_goods'] !== '',function($query) use ($withGoods){
return StoreCart::getDb()->where('uid', $uid)->with([ $query->where('wine_mer_id',$withGoods['with_goods_mer_id']);
},function($query) use ($uid){
$query->where('uid',$uid);
})
->with([
'product' => function(Relation $query) use ($address){ 'product' => function(Relation $query) use ($address){
$query->field('product_id,cate_id,image,store_name,is_show,status,is_del,unit_name,price,mer_status,temp_id,give_coupon_ids,is_gift_bag,is_used,product_type,old_product_id,integral_rate,delivery_way,delivery_free,type,extend,pay_limit,once_max_count,once_min_count,mer_svip_status,svip_price_type,refund_switch,integral_give_switch,integral_give_set,integral_give_type,integral_give_rate,integral_give_money,integral_deduction_type,integral_deduction_money'); $query->field('product_id,cate_id,image,store_name,is_show,status,is_del,unit_name,price,mer_status,temp_id,give_coupon_ids,is_gift_bag,is_used,product_type,old_product_id,integral_rate,delivery_way,delivery_free,type,extend,pay_limit,once_max_count,once_min_count,mer_svip_status,svip_price_type,refund_switch,integral_give_switch,integral_give_set,integral_give_type,integral_give_rate,integral_give_money,integral_deduction_type,integral_deduction_money');
if($address){ if($address){
@ -87,7 +102,9 @@ class StoreCartDao extends BaseDao
$query->whereOr('city_id','like',"%/{$v}/%"); $query->whereOr('city_id','like',"%/{$v}/%");
} }
$query->whereOr('city_id','0'); $query->whereOr('city_id','0');
})->order('shipping_template_region_id DESC')->withLimit(1); })
->order('shipping_template_region_id DESC')
->withLimit(1);
}, },
'undelives' => function($query) use ($cityIds){ 'undelives' => function($query) use ($cityIds){
foreach($cityIds as $v){ foreach($cityIds as $v){
@ -98,8 +115,11 @@ class StoreCartDao extends BaseDao
foreach($cityIds as $v){ foreach($cityIds as $v){
$query->whereOr('city_id','like',"%/{$v}/%"); $query->whereOr('city_id','like',"%/{$v}/%");
} }
$query->order('shipping_template_free_id DESC')->withLimit(1); $query->order('shipping_template_free_id DESC')
}]]); ->withLimit(1);
}
]
]);
} }
}, },
'productAttr' => function(Relation $query){ 'productAttr' => function(Relation $query){
@ -130,7 +150,11 @@ class StoreCartDao extends BaseDao
}, },
'merchantCategory' 'merchantCategory'
]); ]);
}])->whereIn('cart_id', $ids)->order('product_type DESC,cart_id DESC')->select(); }
])
->whereIn('cart_id',$ids)
->order('product_type DESC,cart_id DESC')
->select();
} }
/** /**

View File

@ -100,6 +100,13 @@ class StoreOrderDao extends BaseDao
->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) { ->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
$query->where('uid', $where['uid']); $query->where('uid', $where['uid']);
}) })
->when(isset($where['with_goods_mer_id']) && $where['with_goods_mer_id'] !== '', function ($query) use ($where) {
if($where['with_goods_mer_id'] > 0) $query->where('with_goods_mer_id', $where['with_goods_mer_id']);
},function($query){
$query->where(function($orQuery){
$orQuery->where('with_goods_mer_id', null)->whereOr('with_goods_mer_id','<=', 0);
});
})
->when(isset($where['is_spread']) && $where['is_spread'] !== '', function ($query) use ($where) { ->when(isset($where['is_spread']) && $where['is_spread'] !== '', function ($query) use ($where) {
if ($where['is_spread']) { if ($where['is_spread']) {
$query->where(function($query) { $query->where(function($query) {

View File

@ -34,14 +34,13 @@ use think\facade\{Cache,Db,Log,Queue};
class StoreOrderCreateRepository extends StoreOrderRepository{ class StoreOrderCreateRepository extends StoreOrderRepository{
/****** 原始版本 ************************************/ /****** 原始版本 ************************************/
public function v2CartIdByOrderInfo($user,array $cartId,array $takes = NULL,array $useCoupon = NULL,bool $useIntegral = FALSE,int $addressId = NULL,$createOrder = FALSE){ public function v2CartIdByOrderInfo($user,array $cartId,array $takes = NULL,array $useCoupon = NULL,bool $useIntegral = FALSE,int $addressId = NULL,array $withGoods = [],$createOrder = FALSE){
$uid = $user->uid; $uid = $user->uid;
$userIntegral = $user->integral; $userIntegral = $user->integral;
$isWithGoods = $withGoods['is_with_goods'] ?? 0;// 0=用户购物1=酒道馆进货
$key = md5(json_encode(compact('cartId','takes','useCoupon','useIntegral','addressId'))).$uid; $key = md5(json_encode(compact('cartId','takes','useCoupon','useIntegral','addressId'))).$uid;
//去掉过期的优惠券信息 //去掉过期的优惠券信息
app() app()->make(StoreCouponUserRepository::class)->failCoupon();
->make(StoreCouponUserRepository::class)
->failCoupon();
$address = NULL; $address = NULL;
//验证地址 //验证地址
if($addressId){ if($addressId){
@ -50,7 +49,10 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
} }
$storeCartRepository = app()->make(StoreCartRepository::class); $storeCartRepository = app()->make(StoreCartRepository::class);
//获取购物车信息 //获取购物车信息
$res = $storeCartRepository->checkCartList($storeCartRepository->cartIbByData($cartId,$uid,$address),0,$user); if($isWithGoods) $cartIbByData = $storeCartRepository->cartIbByData($cartId,0,$address,$withGoods);
else $cartIbByData = $storeCartRepository->cartIbByData($cartId,$uid,$address);
$res = $storeCartRepository->checkCartList($cartIbByData,0,$user);
$merchantCartList = $res['list']; $merchantCartList = $res['list'];
$fail = $res['fail']; $fail = $res['fail'];
//检查购物车失效数据 //检查购物车失效数据
@ -87,12 +89,15 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
} }
} }
if($cart['product_type'] > 0) $order_type = $cart['product_type']; if($cart['product_type'] > 0) $order_type = $cart['product_type'];
if($cart['product_type'] != 35){
if($cart['product_type'] > 0 && (($cart['product_type'] != 10 && count($merchantCart['list']) != 1) || count($merchantCartList) != 1)){ if($cart['product_type'] > 0 && (($cart['product_type'] != 10 && count($merchantCart['list']) != 1) || count($merchantCartList) != 1)){
throw new ValidateException('活动商品必须单独购买'); throw new ValidateException('活动商品必须单独购买');
} }
if($cart['product']['type'] && (count($merchantCart['list']) != 1 || count($merchantCartList) != 1)){ if($cart['product']['type'] && (count($merchantCart['list']) != 1 || count($merchantCartList) != 1)){
throw new ValidateException('虚拟商品必须单独购买'); throw new ValidateException('虚拟商品必须单独购买');
} }
}
$order_model = $cart['product']['type']; $order_model = $cart['product']['type'];
if($cart['product']['extend']){ if($cart['product']['extend']){
$order_extend = json_decode($cart['product']['extend'],TRUE); $order_extend = json_decode($cart['product']['extend'],TRUE);
@ -835,9 +840,14 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
$total_price = $order_total_price; $total_price = $order_total_price;
$openIntegral = $merIntegralFlag && !$order_type && $sysIntegralConfig['integral_status'] && $sysIntegralConfig['integral_money'] > 0; $openIntegral = $merIntegralFlag && !$order_type && $sysIntegralConfig['integral_status'] && $sysIntegralConfig['integral_money'] > 0;
$total_coupon = bcadd($order_svip_discount,bcadd(bcadd($total_platform_coupon_price,$order_coupon_price,2),$order_total_integral_price,2),2); $total_coupon = bcadd($order_svip_discount,bcadd(bcadd($total_platform_coupon_price,$order_coupon_price,2),$order_total_integral_price,2),2);
$data = compact('order_type','order_model','order_extend','order_total_postage','order_price','total_price','platformCoupon','enabledPlatformCoupon','usePlatformCouponId','order_total_integral','order_total_integral_price','order_total_give_integral','order_svip_discount','total_platform_coupon_price','total_coupon','order_coupon_price','status','address','openIntegral','useIntegral','key','order_refund_switch','order') + ['allow_address' => !$allow_no_address,
$with_goods_mer_id = $withGoods['with_goods_mer_id'] ?? 0;
$data = compact('with_goods_mer_id','order_type','order_model','order_extend','order_total_postage','order_price','total_price','platformCoupon','enabledPlatformCoupon','usePlatformCouponId','order_total_integral','order_total_integral_price','order_total_give_integral','order_svip_discount','total_platform_coupon_price','total_coupon','order_coupon_price','status','address','openIntegral','useIntegral','key','order_refund_switch','order') + [
'allow_address' => !$allow_no_address,
'order_delivery_status' => $orderDeliveryStatus 'order_delivery_status' => $orderDeliveryStatus
]; ];
Cache::set('order_create_cache'.$uid.'_'.$key,$data,600); Cache::set('order_create_cache'.$uid.'_'.$key,$data,600);
return $data; return $data;
} }
@ -845,6 +855,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
$uid = $user->uid; $uid = $user->uid;
// $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true); // $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true);
$orderInfo = Cache::get('order_create_cache'.$uid.'_'.$key); $orderInfo = Cache::get('order_create_cache'.$uid.'_'.$key);
if(!$orderInfo){ if(!$orderInfo){
throw new ValidateException('订单操作超时,请刷新页面'); throw new ValidateException('订单操作超时,请刷新页面');
} }
@ -872,9 +883,11 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
$extend = []; $extend = [];
} }
$orderType = $orderInfo['order_type']; $orderType = $orderInfo['order_type'];
if($orderType != 35){
if($orderType && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))){ if($orderType && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))){
throw new ValidateException('活动商品请单独购买'); throw new ValidateException('活动商品请单独购买');
} }
}
$merchantCartList = $orderInfo['order']; $merchantCartList = $orderInfo['order'];
$cartSpread = 0; $cartSpread = 0;
$hasTake = FALSE; $hasTake = FALSE;
@ -1042,6 +1055,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'], 'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'],
'pay_type' => $pay_type, 'pay_type' => $pay_type,
'refund_switch' => $merchantCart['order']['order_refund_switch'], 'refund_switch' => $merchantCart['order']['order_refund_switch'],
'with_goods_mer_id' => $orderInfo['with_goods_mer_id'] ?? 0,
]; ];
$allUseCoupon = array_merge($allUseCoupon,$merchantCart['order']['useCouponIds']); $allUseCoupon = array_merge($allUseCoupon,$merchantCart['order']['useCouponIds']);
$orderList[] = $_order; $orderList[] = $_order;
@ -1070,6 +1084,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
'integral_price' => $orderInfo['order_total_integral_price'], 'integral_price' => $orderInfo['order_total_integral_price'],
'give_integral' => $orderInfo['order_total_give_integral'], 'give_integral' => $orderInfo['order_total_give_integral'],
'activity_type' => $orderInfo['order_type'], 'activity_type' => $orderInfo['order_type'],
'with_goods_mer_id' => $orderInfo['with_goods_mer_id'] ?? 0,
]; ];
event('order.create.before',compact('groupOrder','orderList')); event('order.create.before',compact('groupOrder','orderList'));
$group = Db::transaction(function() use ($ex,$user,$topUid,$spreadUid,$uid,$receipt_data,$cartIds,$allUseCoupon,$groupOrder,$orderList,$orderInfo){ $group = Db::transaction(function() use ($ex,$user,$topUid,$spreadUid,$uid,$receipt_data,$cartIds,$allUseCoupon,$groupOrder,$orderList,$orderInfo){

View File

@ -6,6 +6,7 @@ namespace app\common\repositories\store\order;
use app\common\dao\store\order\StoreOrderDao; use app\common\dao\store\order\StoreOrderDao;
use app\common\model\store\order\StoreGroupOrder; use app\common\model\store\order\StoreGroupOrder;
use app\common\model\store\order\StoreOrder; use app\common\model\store\order\StoreOrder;
use app\common\model\system\merchant\Merchant;
use app\common\model\user\User; use app\common\model\user\User;
use app\common\repositories\BaseRepository; use app\common\repositories\BaseRepository;
use app\common\repositories\delivery\DeliveryOrderRepository; use app\common\repositories\delivery\DeliveryOrderRepository;
@ -126,15 +127,30 @@ class StoreOrderRepository extends BaseRepository
* @author xaboy * @author xaboy
* @day 2020/6/9 * @day 2020/6/9
*/ */
public function payBalance(User $user, StoreGroupOrder $groupOrder) public function payBalance(User $user, StoreGroupOrder $groupOrder){
{ if (!systemConfig('yue_pay_status')) throw new ValidateException('未开启余额支付');
if (!systemConfig('yue_pay_status')) if($groupOrder->activity_type == 35){
throw new ValidateException('未开启余额支付'); // 进货订单 扣除商户余额
if ($user['now_money'] < $groupOrder['pay_price']) $merMoney = (float)Merchant::where('mer_id',$groupOrder->with_goods_mer_id)->value('mer_money');
throw new ValidateException('余额不足,请更换支付方式'); $balance = $merMoney ?? 0;
Db::transaction(function () use ($user, $groupOrder) { }else{
// 普通订单 扣除用户余额
$balance = $user['now_money'] ?? 0;
}
if ($balance < $groupOrder['pay_price']) throw new ValidateException('余额不足,请更换支付方式');
Db::transaction(function () use ($user, $groupOrder, $balance) {
if($groupOrder->activity_type == 35){
// 进货订单 扣除商户余额
Merchant::where('mer_id',$groupOrder->with_goods_mer_id)->update([
'mer_money' => bcsub($balance, $groupOrder['pay_price'], 2)
]);
}else{
// 普通订单 扣除用户余额
$user->now_money = bcsub($user->now_money, $groupOrder['pay_price'], 2); $user->now_money = bcsub($user->now_money, $groupOrder['pay_price'], 2);
$user->save(); $user->save();
}
$userBillRepository = app()->make(UserBillRepository::class); $userBillRepository = app()->make(UserBillRepository::class);
$data = [ $data = [
'link_id' => $groupOrder['group_order_id'], 'link_id' => $groupOrder['group_order_id'],
@ -142,7 +158,8 @@ class StoreOrderRepository extends BaseRepository
'title' => '购买商品', 'title' => '购买商品',
'number' => $groupOrder['pay_price'], 'number' => $groupOrder['pay_price'],
'mark' => '余额支付' . floatval($groupOrder['pay_price']) . '元购买商品', 'mark' => '余额支付' . floatval($groupOrder['pay_price']) . '元购买商品',
'balance' => $user->now_money 'balance' => $user->now_money,
'with_goods_mer_id' => $groupOrder->with_goods_mer_id
]; ];
if($groupOrder['activity_type'] == 30){ if($groupOrder['activity_type'] == 30){
$data['title'] = '在线买单'; $data['title'] = '在线买单';
@ -153,6 +170,10 @@ class StoreOrderRepository extends BaseRepository
}else if($groupOrder['activity_type'] == 32){ }else if($groupOrder['activity_type'] == 32){
$data['title'] = '用户申请成为代理人员'; $data['title'] = '用户申请成为代理人员';
$data['mark'] = '余额支付' . floatval($groupOrder['pay_price']) . '元'; $data['mark'] = '余额支付' . floatval($groupOrder['pay_price']) . '元';
}else if($groupOrder['activity_type'] == 35){
$merName = Merchant::where('mer_id',$groupOrder->with_goods_mer_id)->value('mer_name');
$data['title'] = '酒道馆['.$merName.']进货';
$data['mark'] = $user->nickname.'使用商户余额支付' . floatval($groupOrder['pay_price']) . '元';
} }
$userBillRepository->decBill($user['uid'], 'now_money', 'pay_product', $data); $userBillRepository->decBill($user['uid'], 'now_money', 'pay_product', $data);
@ -592,6 +613,20 @@ class StoreOrderRepository extends BaseRepository
return compact('noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all'); return compact('noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all');
} }
public function merOrderNumber(int $merId)
{
$noPay =app()->make(StoreGroupOrderRepository::class)->search(['with_goods_mer_id' => $merId,'is_del' => 0,'paid' => 0],0)->count();
$noPostage = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => 0, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
$all = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => -2,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
$noDeliver = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => 1, 'paid' => 1])->where('StoreOrder.is_del', 0)->count();
$noComment = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => 2, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
$done = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => 3, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
$refund = 0;//app()->make(StoreRefundOrderRepository::class)->getWhereCount(['with_goods_mer_id' => $merId, 'status' => [0, 1, 2]]);
$orderPrice = $this->dao->search(['with_goods_mer_id' => $merId, 'paid' => 1])->sum('pay_price');
$orderCount = $this->dao->search(['with_goods_mer_id' => $merId, 'paid' => 1,'is_user' => 1])->count();
return compact('orderPrice','noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all');
}
/** /**
* @param $id * @param $id
* @param null $uid * @param null $uid

View File

@ -1994,22 +1994,20 @@ class ProductRepository extends BaseRepository
*/ */
public function supplyCartCheck(array $data, $merId){ public function supplyCartCheck(array $data, $merId){
$where = [ $where = [
'is_show' => 1, 'Product.is_show' => 1,
'status' => 1, 'Product.status' => 1,
'is_used' => 1, 'Product.is_used' => 1,
'product_type' => 0, 'Product.product_type' => 0,
'is_gift_bag' => 0,
]; ];
$where['product_id'] = $data['source_id']; $where['product_id'] = $data['source_id'];
unset($where['is_gift_bag']);
// 是否允许购买 // 是否允许购买
$product = $this->dao->search(null, $where) $product = $this->dao->getSearch([])
->hasWhere('merchant', function ($query) use ($where) { ->hasWhere('merchant', function ($query) {
$query->where('is_del', 0) $query->where('is_del', 0)
->where('mer_state', 1)
->where('merchant_type', 2) ->where('merchant_type', 2)
->where('status', 1); ->where('status', 1);
}) })
->where($where)
->findOrEmpty() ->findOrEmpty()
->toArray(); ->toArray();
if (!$product) throw new ValidateException('商品已下架'); if (!$product) throw new ValidateException('商品已下架');

View File

@ -126,6 +126,7 @@ class UserBillRepository extends BaseRepository
$data['type'] = $type; $data['type'] = $type;
$data['uid'] = $uid; $data['uid'] = $uid;
$data['pm'] = $pm; $data['pm'] = $pm;
if (isset($data['with_goods_mer_id']) && $data['with_goods_mer_id'] !== '') $data['with_goods_mer_id'] = $data['with_goods_mer_id'] ?? 0;
$bill = $this->dao->create($data); $bill = $this->dao->create($data);
if($category == 'now_money'){ if($category == 'now_money'){
Queue::push(SendSmsJob::class,['tempId' => 'USER_BALANCE_CHANGE','id' => $bill->bill_id]); Queue::push(SendSmsJob::class,['tempId' => 'USER_BALANCE_CHANGE','id' => $bill->bill_id]);

View File

@ -170,7 +170,7 @@ class Supplier extends BaseController{
'is_del' => 0, 'is_del' => 0,
'is_new' => 0, 'is_new' => 0,
'is_fail' => 0, 'is_fail' => 0,
'product_type' => 30, 'product_type' => 35,
'wine_mer_id' => $merId, 'wine_mer_id' => $merId,
]) ])
->field(['cart_id','product_type','product_id','product_attr_unique','cart_num','is_batch','batch_num']) ->field(['cart_id','product_type','product_id','product_attr_unique','cart_num','is_batch','batch_num'])
@ -202,7 +202,7 @@ class Supplier extends BaseController{
'is_del' => 0, 'is_del' => 0,
'is_new' => 0, 'is_new' => 0,
'is_fail' => 0, 'is_fail' => 0,
'product_type' => 30, 'product_type' => 35,
'wine_mer_id' => $merId, 'wine_mer_id' => $merId,
])->column('cart_id'); ])->column('cart_id');
@ -223,7 +223,7 @@ class Supplier extends BaseController{
'is_batch', 'is_batch',
'batch_num', 'batch_num',
]); ]);
$data['product_type'] = 30; $data['product_type'] = 35;
$data['source'] = $data['product_type']; $data['source'] = $data['product_type'];
$data['source_id'] = $data['product_id']; $data['source_id'] = $data['product_id'];
$merId = $this->request->merId(); $merId = $this->request->merId();
@ -235,7 +235,7 @@ class Supplier extends BaseController{
'is_del' => 0, 'is_del' => 0,
'is_new' => 0, 'is_new' => 0,
'is_fail' => 0, 'is_fail' => 0,
'product_type' => 30, 'product_type' => 35,
'product_id' => $data['source_id'], 'product_id' => $data['source_id'],
'wine_mer_id' => $merId, 'wine_mer_id' => $merId,
'product_attr_unique' => $data['product_attr_unique'], 'product_attr_unique' => $data['product_attr_unique'],
@ -268,7 +268,7 @@ class Supplier extends BaseController{
'product_attr_unique', 'product_attr_unique',
'product_id', 'product_id',
]); ]);
$data['product_type'] = 30; $data['product_type'] = 35;
$data['source'] = $data['product_type']; $data['source'] = $data['product_type'];
$data['source_id'] = $data['product_id']; $data['source_id'] = $data['product_id'];
$merId = $this->request->merId(); $merId = $this->request->merId();
@ -278,7 +278,7 @@ class Supplier extends BaseController{
'is_del' => 0, 'is_del' => 0,
'is_new' => 0, 'is_new' => 0,
'is_fail' => 0, 'is_fail' => 0,
'product_type' => 30, 'product_type' => 35,
'product_id' => $data['source_id'], 'product_id' => $data['source_id'],
'wine_mer_id' => $merId, 'wine_mer_id' => $merId,
'product_attr_unique' => $data['product_attr_unique'], 'product_attr_unique' => $data['product_attr_unique'],

View File

@ -44,8 +44,11 @@ class StoreOrder extends BaseController
$this->repository = $repository; $this->repository = $repository;
} }
public function v2CheckOrder(StoreCartRepository $cartRepository, StoreOrderCreateRepository $orderCreateRepository) public function v2CheckOrder(StoreCartRepository $cartRepository, StoreOrderCreateRepository $orderCreateRepository){
{ $withGoods = $this->request->params([
['is_with_goods',0],
['with_goods_mer_id',0]
]);
$cartId = (array)$this->request->param('cart_id', []); $cartId = (array)$this->request->param('cart_id', []);
$addressId = (int)$this->request->param('address_id'); $addressId = (int)$this->request->param('address_id');
$couponIds = (array)$this->request->param('use_coupon', []); $couponIds = (array)$this->request->param('use_coupon', []);
@ -55,16 +58,29 @@ class StoreOrder extends BaseController
$useIntegral = (bool)$this->request->param('use_integral', false); $useIntegral = (bool)$this->request->param('use_integral', false);
$user = $this->request->userInfo(); $user = $this->request->userInfo();
$uid = $user->uid; $uid = $user->uid;
if (!($count = count($cartId)) || $count != count($cartRepository->validIntersection($cartId, $uid)))
return app('json')->fail('数据无效'); if($withGoods['is_with_goods'] == 1){
// 商户进货
$cartCount = count($cartRepository->ShopValidIntersection($cartId, $withGoods['with_goods_mer_id']));
}else{
// 用户购物
$cartCount = count($cartRepository->validIntersection($cartId, $uid));
}
if (!($count = count($cartId)) || $count != $cartCount) return app('json')->fail('数据无效');
// $orderInfo = $orderCreateRepository->v2CartIdByOrderInfo($user, $cartId, $takes, $couponIds, $usePlatformIntegral,$useMerIntegral, $addressId); // $orderInfo = $orderCreateRepository->v2CartIdByOrderInfo($user, $cartId, $takes, $couponIds, $usePlatformIntegral,$useMerIntegral, $addressId);
$orderInfo = $orderCreateRepository->v2CartIdByOrderInfo($user, $cartId, $takes, $couponIds, $useIntegral, $addressId); $orderInfo = $orderCreateRepository->v2CartIdByOrderInfo($user, $cartId, $takes, $couponIds, $useIntegral, $addressId, $withGoods);
return app('json')->success($orderInfo); return app('json')->success($orderInfo);
} }
public function v2CreateOrder(StoreCartRepository $cartRepository, StoreOrderCreateRepository $orderCreateRepository) public function v2CreateOrder(StoreCartRepository $cartRepository, StoreOrderCreateRepository $orderCreateRepository)
{ {
$withGoods = $this->request->params([
['is_with_goods',0],
['with_goods_mer_id',0]
]);
$cartId = (array)$this->request->param('cart_id', []); $cartId = (array)$this->request->param('cart_id', []);
$addressId = (int)$this->request->param('address_id'); $addressId = (int)$this->request->param('address_id');
$couponIds = (array)$this->request->param('use_coupon', []); $couponIds = (array)$this->request->param('use_coupon', []);
@ -96,8 +112,16 @@ class StoreOrder extends BaseController
} }
$uid = $this->request->uid(); $uid = $this->request->uid();
if (!($count = count($cartId)) || $count != count($cartRepository->validIntersection($cartId, $uid)))
return app('json')->fail('数据无效'); if($withGoods['is_with_goods'] == 1){
// 商户进货
$cartCount = count($cartRepository->ShopValidIntersection($cartId, $withGoods['with_goods_mer_id']));
}else{
// 用户购物
$cartCount = count($cartRepository->validIntersection($cartId, $uid));
}
if (!($count = count($cartId)) || $count != $cartCount) return app('json')->fail('数据无效');
// if (!$addressId) // if (!$addressId)
// return app('json')->fail('请选择地址'); // return app('json')->fail('请选择地址');
@ -134,6 +158,9 @@ class StoreOrder extends BaseController
public function lst() public function lst()
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$where['is_with_goods'] = $this->request->param('is_with_goods', 0);
$where['with_goods_mer_id'] = $this->request->param('with_goods_mer_id', 0);
if($where['is_with_goods'] != 1) $where['with_goods_mer_id'] = '';
$where['status'] = $this->request->param('status'); $where['status'] = $this->request->param('status');
$where['search'] = $this->request->param('store_name'); $where['search'] = $this->request->param('store_name');
$where['uid'] = $this->request->uid(); $where['uid'] = $this->request->uid();
@ -164,9 +191,20 @@ class StoreOrder extends BaseController
* @author xaboy * @author xaboy
* @day 2020/6/10 * @day 2020/6/10
*/ */
public function number() public function number(){
{ $is_with_goods = $this->request->param('is_with_goods', 0);
return app('json')->success(['orderPrice' => $this->request->userInfo()->pay_price] + $this->repository->userOrderNumber($this->request->uid())); $with_goods_mer_id = $this->request->param('with_goods_mer_id', 0);
if($is_with_goods == 1){
$data = $this->repository->merOrderNumber($with_goods_mer_id);
}else{
$data = ['orderPrice' => $this->request->userInfo()->pay_price];
$data2 = $this->repository->userOrderNumber($this->request->uid());
$data = $data + $data2;
}
return app('json')->success($data);
} }
/** /**