添加:酒道馆进货流程 - 下单及支付流程
This commit is contained in:
parent
a94c70a9f5
commit
363a84c7dc
|
|
@ -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');
|
||||
}
|
||||
|
||||
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
|
||||
* @Date: 2020/6/1
|
||||
|
|
@ -71,66 +82,79 @@ class StoreCartDao extends BaseDao
|
|||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function cartIbByData(array $ids, int $uid, ?UserAddress $address)
|
||||
{
|
||||
return StoreCart::getDb()->where('uid', $uid)->with([
|
||||
'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');
|
||||
if ($address) {
|
||||
$cityIds = array_filter([$address->province_id, $address->city_id, $address->district_id, $address->street_id]);
|
||||
$query->with([
|
||||
'temp' => [
|
||||
'region' => function (Relation $query) use ($cityIds) {
|
||||
$query->where(function ($query) use ($cityIds) {
|
||||
foreach ($cityIds as $v) {
|
||||
$query->whereOr('city_id', 'like', "%/{$v}/%");
|
||||
public function cartIbByData(array $ids,int $uid,?UserAddress $address,$withGoods = []){
|
||||
return StoreCart::getDb()
|
||||
->when(isset($withGoods['is_with_goods']) && $withGoods['is_with_goods'] !== '',function($query) use ($withGoods){
|
||||
$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){
|
||||
$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){
|
||||
$cityIds = array_filter([$address->province_id,$address->city_id,$address->district_id,$address->street_id]);
|
||||
$query->with([
|
||||
'temp' => [
|
||||
'region' => function(Relation $query) use ($cityIds){
|
||||
$query->where(function($query) use ($cityIds){
|
||||
foreach($cityIds as $v){
|
||||
$query->whereOr('city_id','like',"%/{$v}/%");
|
||||
}
|
||||
$query->whereOr('city_id','0');
|
||||
})
|
||||
->order('shipping_template_region_id DESC')
|
||||
->withLimit(1);
|
||||
},
|
||||
'undelives' => function($query) use ($cityIds){
|
||||
foreach($cityIds as $v){
|
||||
$query->whereOr('city_id','like',"%/{$v}/%");
|
||||
}
|
||||
$query->whereOr('city_id', '0');
|
||||
})->order('shipping_template_region_id DESC')->withLimit(1);
|
||||
},
|
||||
'undelives' => function ($query) use ($cityIds) {
|
||||
foreach ($cityIds as $v) {
|
||||
$query->whereOr('city_id', 'like', "%/{$v}/%");
|
||||
},
|
||||
'free' => function(Relation $query) use ($cityIds){
|
||||
foreach($cityIds as $v){
|
||||
$query->whereOr('city_id','like',"%/{$v}/%");
|
||||
}
|
||||
$query->order('shipping_template_free_id DESC')
|
||||
->withLimit(1);
|
||||
}
|
||||
},
|
||||
'free' => function (Relation $query) use ($cityIds) {
|
||||
foreach ($cityIds as $v) {
|
||||
$query->whereOr('city_id', 'like', "%/{$v}/%");
|
||||
}
|
||||
$query->order('shipping_template_free_id DESC')->withLimit(1);
|
||||
}]]);
|
||||
}
|
||||
},
|
||||
'productAttr' => function (Relation $query) {
|
||||
$query->field('value_id,image,extension_one,extension_two,product_id,stock,price,unique,sku,volume,weight,ot_price,cost,svip_price')
|
||||
->append(['bc_extension_one', 'bc_extension_two']);
|
||||
},
|
||||
'merchant' => function (Relation $query) use ($uid) {
|
||||
$query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id')
|
||||
->with([
|
||||
'coupon' => function ($query) use ($uid) {
|
||||
$query->where('uid', $uid);
|
||||
},
|
||||
'config' => function ($query) {
|
||||
$query->whereIn('config_key',[
|
||||
'mer_integral_status',
|
||||
'mer_integral_rate',
|
||||
'mer_integral_money',
|
||||
'mer_integral_order_rate',
|
||||
'mer_store_stock',
|
||||
'mer_take_status',
|
||||
'mer_take_name',
|
||||
'mer_take_phone',
|
||||
'mer_take_address',
|
||||
'mer_take_location',
|
||||
'mer_take_day',
|
||||
'mer_take_time'
|
||||
]
|
||||
]);
|
||||
},
|
||||
'merchantCategory'
|
||||
]);
|
||||
}])->whereIn('cart_id', $ids)->order('product_type DESC,cart_id DESC')->select();
|
||||
}
|
||||
},
|
||||
'productAttr' => function(Relation $query){
|
||||
$query->field('value_id,image,extension_one,extension_two,product_id,stock,price,unique,sku,volume,weight,ot_price,cost,svip_price')
|
||||
->append(['bc_extension_one','bc_extension_two']);
|
||||
},
|
||||
'merchant' => function(Relation $query) use ($uid){
|
||||
$query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id')
|
||||
->with([
|
||||
'coupon' => function($query) use ($uid){
|
||||
$query->where('uid',$uid);
|
||||
},
|
||||
'config' => function($query){
|
||||
$query->whereIn('config_key',[
|
||||
'mer_integral_status',
|
||||
'mer_integral_rate',
|
||||
'mer_integral_money',
|
||||
'mer_integral_order_rate',
|
||||
'mer_store_stock',
|
||||
'mer_take_status',
|
||||
'mer_take_name',
|
||||
'mer_take_phone',
|
||||
'mer_take_address',
|
||||
'mer_take_location',
|
||||
'mer_take_day',
|
||||
'mer_take_time'
|
||||
]);
|
||||
},
|
||||
'merchantCategory'
|
||||
]);
|
||||
}
|
||||
])
|
||||
->whereIn('cart_id',$ids)
|
||||
->order('product_type DESC,cart_id DESC')
|
||||
->select();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -100,6 +100,13 @@ class StoreOrderDao extends BaseDao
|
|||
->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
|
||||
$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) {
|
||||
if ($where['is_spread']) {
|
||||
$query->where(function($query) {
|
||||
|
|
|
|||
|
|
@ -34,14 +34,13 @@ use think\facade\{Cache,Db,Log,Queue};
|
|||
|
||||
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;
|
||||
$userIntegral = $user->integral;
|
||||
$key = md5(json_encode(compact('cartId','takes','useCoupon','useIntegral','addressId'))).$uid;
|
||||
$isWithGoods = $withGoods['is_with_goods'] ?? 0;// 0=用户购物,1=酒道馆进货
|
||||
$key = md5(json_encode(compact('cartId','takes','useCoupon','useIntegral','addressId'))).$uid;
|
||||
//去掉过期的优惠券信息
|
||||
app()
|
||||
->make(StoreCouponUserRepository::class)
|
||||
->failCoupon();
|
||||
app()->make(StoreCouponUserRepository::class)->failCoupon();
|
||||
$address = NULL;
|
||||
//验证地址
|
||||
if($addressId){
|
||||
|
|
@ -50,7 +49,10 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
|
|||
}
|
||||
$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'];
|
||||
$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 && (($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)){
|
||||
throw new ValidateException('虚拟商品必须单独购买');
|
||||
if($cart['product_type'] != 35){
|
||||
if($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)){
|
||||
throw new ValidateException('虚拟商品必须单独购买');
|
||||
}
|
||||
}
|
||||
|
||||
$order_model = $cart['product']['type'];
|
||||
if($cart['product']['extend']){
|
||||
$order_extend = json_decode($cart['product']['extend'],TRUE);
|
||||
|
|
@ -835,9 +840,14 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
|
|||
$total_price = $order_total_price;
|
||||
$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);
|
||||
$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,
|
||||
'order_delivery_status' => $orderDeliveryStatus
|
||||
|
||||
$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
|
||||
];
|
||||
|
||||
Cache::set('order_create_cache'.$uid.'_'.$key,$data,600);
|
||||
return $data;
|
||||
}
|
||||
|
|
@ -845,6 +855,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
|
|||
$uid = $user->uid;
|
||||
// $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true);
|
||||
$orderInfo = Cache::get('order_create_cache'.$uid.'_'.$key);
|
||||
|
||||
if(!$orderInfo){
|
||||
throw new ValidateException('订单操作超时,请刷新页面');
|
||||
}
|
||||
|
|
@ -872,8 +883,10 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
|
|||
$extend = [];
|
||||
}
|
||||
$orderType = $orderInfo['order_type'];
|
||||
if($orderType && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))){
|
||||
throw new ValidateException('活动商品请单独购买');
|
||||
if($orderType != 35){
|
||||
if($orderType && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))){
|
||||
throw new ValidateException('活动商品请单独购买');
|
||||
}
|
||||
}
|
||||
$merchantCartList = $orderInfo['order'];
|
||||
$cartSpread = 0;
|
||||
|
|
@ -1042,6 +1055,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
|
|||
'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'],
|
||||
'pay_type' => $pay_type,
|
||||
'refund_switch' => $merchantCart['order']['order_refund_switch'],
|
||||
'with_goods_mer_id' => $orderInfo['with_goods_mer_id'] ?? 0,
|
||||
];
|
||||
$allUseCoupon = array_merge($allUseCoupon,$merchantCart['order']['useCouponIds']);
|
||||
$orderList[] = $_order;
|
||||
|
|
@ -1070,6 +1084,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
|
|||
'integral_price' => $orderInfo['order_total_integral_price'],
|
||||
'give_integral' => $orderInfo['order_total_give_integral'],
|
||||
'activity_type' => $orderInfo['order_type'],
|
||||
'with_goods_mer_id' => $orderInfo['with_goods_mer_id'] ?? 0,
|
||||
];
|
||||
event('order.create.before',compact('groupOrder','orderList'));
|
||||
$group = Db::transaction(function() use ($ex,$user,$topUid,$spreadUid,$uid,$receipt_data,$cartIds,$allUseCoupon,$groupOrder,$orderList,$orderInfo){
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ namespace app\common\repositories\store\order;
|
|||
use app\common\dao\store\order\StoreOrderDao;
|
||||
use app\common\model\store\order\StoreGroupOrder;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\User;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\delivery\DeliveryOrderRepository;
|
||||
|
|
@ -126,15 +127,30 @@ class StoreOrderRepository extends BaseRepository
|
|||
* @author xaboy
|
||||
* @day 2020/6/9
|
||||
*/
|
||||
public function payBalance(User $user, StoreGroupOrder $groupOrder)
|
||||
{
|
||||
if (!systemConfig('yue_pay_status'))
|
||||
throw new ValidateException('未开启余额支付');
|
||||
if ($user['now_money'] < $groupOrder['pay_price'])
|
||||
throw new ValidateException('余额不足,请更换支付方式');
|
||||
Db::transaction(function () use ($user, $groupOrder) {
|
||||
$user->now_money = bcsub($user->now_money, $groupOrder['pay_price'], 2);
|
||||
$user->save();
|
||||
public function payBalance(User $user, StoreGroupOrder $groupOrder){
|
||||
if (!systemConfig('yue_pay_status')) throw new ValidateException('未开启余额支付');
|
||||
if($groupOrder->activity_type == 35){
|
||||
// 进货订单 扣除商户余额
|
||||
$merMoney = (float)Merchant::where('mer_id',$groupOrder->with_goods_mer_id)->value('mer_money');
|
||||
$balance = $merMoney ?? 0;
|
||||
}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->save();
|
||||
}
|
||||
|
||||
$userBillRepository = app()->make(UserBillRepository::class);
|
||||
$data = [
|
||||
'link_id' => $groupOrder['group_order_id'],
|
||||
|
|
@ -142,7 +158,8 @@ class StoreOrderRepository extends BaseRepository
|
|||
'title' => '购买商品',
|
||||
'number' => $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){
|
||||
$data['title'] = '在线买单';
|
||||
|
|
@ -153,6 +170,10 @@ class StoreOrderRepository extends BaseRepository
|
|||
}else if($groupOrder['activity_type'] == 32){
|
||||
$data['title'] = '用户申请成为代理人员';
|
||||
$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);
|
||||
|
|
@ -592,6 +613,20 @@ class StoreOrderRepository extends BaseRepository
|
|||
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 null $uid
|
||||
|
|
|
|||
|
|
@ -1994,22 +1994,20 @@ class ProductRepository extends BaseRepository
|
|||
*/
|
||||
public function supplyCartCheck(array $data, $merId){
|
||||
$where = [
|
||||
'is_show' => 1,
|
||||
'status' => 1,
|
||||
'is_used' => 1,
|
||||
'product_type' => 0,
|
||||
'is_gift_bag' => 0,
|
||||
'Product.is_show' => 1,
|
||||
'Product.status' => 1,
|
||||
'Product.is_used' => 1,
|
||||
'Product.product_type' => 0,
|
||||
];
|
||||
$where['product_id'] = $data['source_id'];
|
||||
unset($where['is_gift_bag']);
|
||||
// 是否允许购买
|
||||
$product = $this->dao->search(null, $where)
|
||||
->hasWhere('merchant', function ($query) use ($where) {
|
||||
$product = $this->dao->getSearch([])
|
||||
->hasWhere('merchant', function ($query) {
|
||||
$query->where('is_del', 0)
|
||||
->where('mer_state', 1)
|
||||
->where('merchant_type', 2)
|
||||
->where('status', 1);
|
||||
})
|
||||
->where($where)
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
if (!$product) throw new ValidateException('商品已下架');
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ class UserBillRepository extends BaseRepository
|
|||
$data['type'] = $type;
|
||||
$data['uid'] = $uid;
|
||||
$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);
|
||||
if($category == 'now_money'){
|
||||
Queue::push(SendSmsJob::class,['tempId' => 'USER_BALANCE_CHANGE','id' => $bill->bill_id]);
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class Supplier extends BaseController{
|
|||
'is_del' => 0,
|
||||
'is_new' => 0,
|
||||
'is_fail' => 0,
|
||||
'product_type' => 30,
|
||||
'product_type' => 35,
|
||||
'wine_mer_id' => $merId,
|
||||
])
|
||||
->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_new' => 0,
|
||||
'is_fail' => 0,
|
||||
'product_type' => 30,
|
||||
'product_type' => 35,
|
||||
'wine_mer_id' => $merId,
|
||||
])->column('cart_id');
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ class Supplier extends BaseController{
|
|||
'is_batch',
|
||||
'batch_num',
|
||||
]);
|
||||
$data['product_type'] = 30;
|
||||
$data['product_type'] = 35;
|
||||
$data['source'] = $data['product_type'];
|
||||
$data['source_id'] = $data['product_id'];
|
||||
$merId = $this->request->merId();
|
||||
|
|
@ -235,7 +235,7 @@ class Supplier extends BaseController{
|
|||
'is_del' => 0,
|
||||
'is_new' => 0,
|
||||
'is_fail' => 0,
|
||||
'product_type' => 30,
|
||||
'product_type' => 35,
|
||||
'product_id' => $data['source_id'],
|
||||
'wine_mer_id' => $merId,
|
||||
'product_attr_unique' => $data['product_attr_unique'],
|
||||
|
|
@ -268,7 +268,7 @@ class Supplier extends BaseController{
|
|||
'product_attr_unique',
|
||||
'product_id',
|
||||
]);
|
||||
$data['product_type'] = 30;
|
||||
$data['product_type'] = 35;
|
||||
$data['source'] = $data['product_type'];
|
||||
$data['source_id'] = $data['product_id'];
|
||||
$merId = $this->request->merId();
|
||||
|
|
@ -278,7 +278,7 @@ class Supplier extends BaseController{
|
|||
'is_del' => 0,
|
||||
'is_new' => 0,
|
||||
'is_fail' => 0,
|
||||
'product_type' => 30,
|
||||
'product_type' => 35,
|
||||
'product_id' => $data['source_id'],
|
||||
'wine_mer_id' => $merId,
|
||||
'product_attr_unique' => $data['product_attr_unique'],
|
||||
|
|
|
|||
|
|
@ -44,8 +44,11 @@ class StoreOrder extends BaseController
|
|||
$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', []);
|
||||
$addressId = (int)$this->request->param('address_id');
|
||||
$couponIds = (array)$this->request->param('use_coupon', []);
|
||||
|
|
@ -55,16 +58,29 @@ class StoreOrder extends BaseController
|
|||
$useIntegral = (bool)$this->request->param('use_integral', false);
|
||||
$user = $this->request->userInfo();
|
||||
$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, $useIntegral, $addressId);
|
||||
$orderInfo = $orderCreateRepository->v2CartIdByOrderInfo($user, $cartId, $takes, $couponIds, $useIntegral, $addressId, $withGoods);
|
||||
|
||||
return app('json')->success($orderInfo);
|
||||
}
|
||||
|
||||
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', []);
|
||||
$addressId = (int)$this->request->param('address_id');
|
||||
$couponIds = (array)$this->request->param('use_coupon', []);
|
||||
|
|
@ -96,8 +112,16 @@ class StoreOrder extends BaseController
|
|||
}
|
||||
|
||||
$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)
|
||||
// return app('json')->fail('请选择地址');
|
||||
|
||||
|
|
@ -134,6 +158,9 @@ class StoreOrder extends BaseController
|
|||
public function lst()
|
||||
{
|
||||
[$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['search'] = $this->request->param('store_name');
|
||||
$where['uid'] = $this->request->uid();
|
||||
|
|
@ -164,9 +191,20 @@ class StoreOrder extends BaseController
|
|||
* @author xaboy
|
||||
* @day 2020/6/10
|
||||
*/
|
||||
public function number()
|
||||
{
|
||||
return app('json')->success(['orderPrice' => $this->request->userInfo()->pay_price] + $this->repository->userOrderNumber($this->request->uid()));
|
||||
public function number(){
|
||||
$is_with_goods = $this->request->param('is_with_goods', 0);
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue