调整商品批发价
This commit is contained in:
parent
4f0d5b2dd9
commit
e4fdf06f22
@ -58,10 +58,10 @@ class StoreCartDao extends BaseDao
|
||||
$query = ($this->getModel())::where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0, 'sale_type' => $saleType])
|
||||
->with([
|
||||
'product' => function ($query) {
|
||||
$query->field('product_id,image,store_name,is_show,status,is_del,unit_name,price,mer_status,is_used,product_type,once_max_count,once_min_count,pay_limit,mer_svip_status,svip_price_type');
|
||||
$query->field('product_id,image,store_name,is_show,status,is_del,unit_name,price,mer_status,is_used,product_type,once_max_count,once_min_count,pay_limit,mer_svip_status,svip_price_type,wholesale_price');
|
||||
},
|
||||
'productAttr' => function ($query) {
|
||||
$query->field('product_id,stock,price,unique,sku,image,svip_price');
|
||||
$query->field('product_id,stock,price,unique,sku,image,svip_price,wholesale_price');
|
||||
},
|
||||
'merchant' => function ($query) {
|
||||
$query->field('mer_id,mer_name,mer_state,mer_avatar,is_trader,type_id')->with(['type_name']);
|
||||
|
@ -70,6 +70,9 @@ class StoreGroupOrderDao extends BaseDao
|
||||
$query->where('activity_type', '<>',20);
|
||||
}
|
||||
})
|
||||
->when(isset($where['sale_type']) && $where['sale_type'] !== '', function ($query) use ($where) {
|
||||
$query->where('sale_type', $where['sale_type']);
|
||||
})
|
||||
->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) {
|
||||
$query->where('is_del', $where['is_del']);
|
||||
}, function ($query) {
|
||||
|
@ -36,6 +36,7 @@ class StoreCartRepository extends BaseRepository
|
||||
{
|
||||
//购物车最大条数
|
||||
const CART_LIMIT_COUNT = 99;
|
||||
public $saleType = 1;
|
||||
|
||||
/**
|
||||
* StoreCartRepository constructor.
|
||||
@ -54,6 +55,7 @@ class StoreCartRepository extends BaseRepository
|
||||
*/
|
||||
public function getList($user, int $saleType = 1)
|
||||
{
|
||||
$this->saleType = $saleType;
|
||||
$res = $this->dao->getAll($user->uid, $saleType)->append(['checkCartProduct', 'UserPayCount', 'ActiveSku','spu']);
|
||||
return $this->checkCartList($res, $user->uid, $user);
|
||||
}
|
||||
@ -102,6 +104,11 @@ class StoreCartRepository extends BaseRepository
|
||||
} else {
|
||||
$item['productAttr']['show_svip_price'] = false;
|
||||
}
|
||||
if ($this->saleType == Enum::SALE_TYPE_WHOLESALE && $item['product']['wholesale_price'] > 0) {
|
||||
$item['product']['price'] = $item['product']['wholesale_price'];
|
||||
$item['productAttr']['price'] = $item['productAttr']['wholesale_price'];
|
||||
$item['ActiveSku']['price'] = $item['ActiveSku']['wholesale_price'];
|
||||
}
|
||||
$arr[$item['mer_id']]['list'][] = $item;
|
||||
}
|
||||
}
|
||||
@ -132,6 +139,9 @@ class StoreCartRepository extends BaseRepository
|
||||
public function getCartByProductSku($sku,$uid)
|
||||
{
|
||||
$where = ['is_del'=>0,'is_fail'=>0,'is_new'=>0,'is_pay'=>0,'uid' => $uid,'product_type' => 0,'product_attr_unique' => $sku];
|
||||
if (!empty($this->saleType)) {
|
||||
$where['sale_type'] = $this->saleType;
|
||||
}
|
||||
return ($this->dao->getWhere($where));
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$userCouponRepo = app()->make(StoreCouponUserRepository::class);
|
||||
foreach ($merchantCartList as &$merchantCart) {
|
||||
$isPlatformCard = $userCouponRepo->checkBuyLimit($merchantCart['list'], $uid);
|
||||
//用户关联了商户id且下单店铺支持批发
|
||||
$isWholeSale = StoreOrder::isWholesale($merchantCart['wholesale'], $merId, $this->saleType);
|
||||
$postageRule = [];
|
||||
$total_price = 0;
|
||||
$total_num = 0;
|
||||
@ -114,6 +112,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$product_cart = [];
|
||||
|
||||
foreach ($merchantCart['list'] as $k => $cart) {
|
||||
//用户关联了商户id且下单店铺支持批发
|
||||
$isWholeSale = StoreOrder::isWholesale($merchantCart['wholesale'], $merId, $cart['sale_type']);
|
||||
if ($isWholeSale) {
|
||||
$merchantCart['list'][$k]['productAttr']['price'] = $cart['productAttr']['wholesale_price'];
|
||||
$merchantCart['list'][$k]['product']['price'] = $cart['productAttr']['wholesale_price'];
|
||||
@ -1001,6 +1001,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$totalCost = 0;
|
||||
$cartIds = [];
|
||||
$orderList = [];
|
||||
$saleType = 0;
|
||||
|
||||
foreach ($merchantCartList as $k => $merchantCart) {
|
||||
$cost = 0;
|
||||
@ -1008,6 +1009,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$total_extension_two = 0;
|
||||
//计算佣金和赠送的优惠券
|
||||
foreach ($merchantCart['list'] as &$cart) {
|
||||
$saleType = $saleType == 0 ? $cart['sale_type'] : $saleType;
|
||||
$cartIds[] = $cart['cart_id'];
|
||||
$giveCouponIds = array_merge($giveCouponIds, $cart['product']['give_coupon_ids'] ?: []);
|
||||
$cart['cost'] = $cart['productAttr']['cost'];
|
||||
@ -1121,7 +1123,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'],
|
||||
'pay_type' => $pay_type,
|
||||
'refund_switch' => $merchantCart['order']['order_refund_switch'],
|
||||
'sale_type' => $orderInfo['sale_type'],
|
||||
'sale_type' => $saleType,
|
||||
];
|
||||
$allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']);
|
||||
$orderList[] = $_order;
|
||||
@ -1149,6 +1151,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'integral_price' => $orderInfo['order_total_integral_price'],
|
||||
'give_integral' => $orderInfo['order_total_give_integral'],
|
||||
'activity_type' => $orderInfo['order_type'],
|
||||
'sale_type' => $saleType,
|
||||
];
|
||||
event('order.create.before', compact('groupOrder', 'orderList'));
|
||||
$group = Db::transaction(function () use ($ex, $user, $topUid, $spreadUid, $uid, $receipt_data, $cartIds, $allUseCoupon, $groupOrder, $orderList, $orderInfo, $useCoupon) {
|
||||
|
@ -1370,7 +1370,7 @@ class ProductRepository extends BaseRepository
|
||||
|
||||
public function apiProductDetail($where, int $productType, ?int $activityId, $userInfo = null)
|
||||
{
|
||||
$field = 'is_show,product_id,mer_id,image,slider_image,store_name,store_info,unit_name,price,cost,ot_price,stock,sales,video_link,product_type,extension_type,old_product_id,rate,guarantee_template_id,temp_id,once_max_count,pay_limit,once_min_count,integral_rate,delivery_way,delivery_free,type,cate_id,svip_price_type,svip_price,mer_svip_status,mer_form_id';
|
||||
$field = 'is_show,product_id,mer_id,image,slider_image,store_name,store_info,unit_name,price,cost,ot_price,stock,sales,video_link,product_type,extension_type,old_product_id,rate,guarantee_template_id,temp_id,once_max_count,pay_limit,once_min_count,integral_rate,delivery_way,delivery_free,type,cate_id,svip_price_type,svip_price,mer_svip_status,mer_form_id,wholesale_price';
|
||||
$with = [
|
||||
'attr',
|
||||
'attrValue',
|
||||
@ -1446,8 +1446,8 @@ class ProductRepository extends BaseRepository
|
||||
$product['attr'] = $attr;
|
||||
$product['sku'] = $sku;
|
||||
$product['isRelation'] = $isRelation;
|
||||
if ($this->isWholesale) {
|
||||
$product['price'] = current($sku)['price'];
|
||||
if ($this->isWholesale && $product['wholesale_price'] > 0) {
|
||||
$product['price'] = $product['wholesale_price'];
|
||||
}
|
||||
return $product;
|
||||
}
|
||||
@ -1695,6 +1695,7 @@ class ProductRepository extends BaseRepository
|
||||
$_value = [
|
||||
'sku' => $value['sku'],
|
||||
'price' => $value['price'],
|
||||
'wholesale_price' => $value['wholesale_price'],
|
||||
'stock' => $value['stock'],
|
||||
'image' => $value['image'],
|
||||
'weight' => $value['weight'],
|
||||
@ -1737,6 +1738,9 @@ class ProductRepository extends BaseRepository
|
||||
$_value['extension_one'] = $value->bc_extension_one;
|
||||
$_value['extension_two'] = $value->bc_extension_two;
|
||||
}
|
||||
if ($this->isWholesale && $_value['wholesale_price'] > 0) {
|
||||
$_value['price'] = $_value['wholesale_price'];
|
||||
}
|
||||
$sku[$value['sku']] = $_value;
|
||||
}
|
||||
return $sku;
|
||||
@ -2126,7 +2130,10 @@ class ProductRepository extends BaseRepository
|
||||
if ($sku['stock'] < $cart_num) throw new ValidateException('库存不足');
|
||||
//添加购物车
|
||||
if (!$data['is_new']) {
|
||||
$cart = app()->make(StoreCartRepository::class)->getCartByProductSku($data['product_attr_unique'], $userInfo->uid);
|
||||
/** @var StoreCartRepository $repo */
|
||||
$repo = app()->make(StoreCartRepository::class);
|
||||
$repo->saleType = $data['sale_type'];
|
||||
$cart = $repo->getCartByProductSku($data['product_attr_unique'], $userInfo->uid);
|
||||
}
|
||||
|
||||
return compact('product', 'sku', 'cart');
|
||||
|
@ -10,6 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\common\repositories\store\product;
|
||||
|
||||
use app\common\Enum;
|
||||
use app\common\repositories\store\coupon\StoreCouponProductRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
use app\common\repositories\store\parameter\ParameterValueRepository;
|
||||
@ -167,6 +168,11 @@ class SpuRepository extends BaseRepository
|
||||
$append[] = 'max_extension';
|
||||
$list->append($append);
|
||||
$list = $this->getBorderList($list);
|
||||
foreach ($list as &$item) {
|
||||
if ($where['sale_type'] == Enum::SALE_TYPE_WHOLESALE && $item['wholesale_price'] > 0) {
|
||||
$item['price']= $item['wholesale_price'];
|
||||
}
|
||||
}
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,8 @@ class StoreOrder extends BaseController
|
||||
public function groupOrderList(StoreGroupOrderRepository $groupOrderRepository)
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$list = $groupOrderRepository->getList(['uid' => $this->request->uid(), 'paid' => 0], $page, $limit);
|
||||
$saleType = $this->request->get('sale_type', 1);
|
||||
$list = $groupOrderRepository->getList(['uid' => $this->request->uid(), 'paid' => 0, 'sale_type' => $saleType], $page, $limit);
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
@ -345,6 +346,6 @@ class StoreOrder extends BaseController
|
||||
$this->repository->dealVerify($img,$id);
|
||||
return app('json')->success('上传凭证成功');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user