Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
liu 2024-03-15 14:03:55 +08:00
commit f2a93affe3
8 changed files with 35 additions and 15 deletions

View File

@ -50,11 +50,12 @@ class StoreCartDao extends BaseDao
* @Author:Qinii
* @Date: 2020/6/1
* @param int $uid
* @param int $saleType
* @return mixed
*/
public function getAll(int $uid)
public function getAll(int $uid, int $saleType = 1)
{
$query = ($this->getModel())::where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0])
$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');
@ -133,9 +134,9 @@ class StoreCartDao extends BaseDao
* @return mixed
* @author Qinii
*/
public function getCartCount(int $uid)
public function getCartCount(int $uid, int $saleType)
{
$data = ($this->getModel()::getDB())->where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0])->field('SUM(cart_num) as count')->select();
$data = ($this->getModel()::getDB())->where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0, 'sale_type' => $saleType])->field('SUM(cart_num) as count')->select();
$data[0]['count'] = $data[0]['count'] ? $data[0]['count'] : 0;
return $data;
}

View File

@ -73,9 +73,12 @@ class SpuDao extends BaseDao
$query->whereIn('P.mer_id',$where['mer_ids']);
})
->when(isset($where['sale_type']) && $where['sale_type'] !== '',function($query)use($where){
$saleType = $where['sale_type'] == Enum::SALE_TYPE_RETAIL ? [Enum::RETAIL_ONLY, Enum::RETAIL_WHOLESALE] : [Enum::WHOLESALE_ONLY];
$saleType = $where['sale_type'] == Enum::SALE_TYPE_RETAIL ? [Enum::RETAIL_ONLY, Enum::RETAIL_WHOLESALE] : [Enum::WHOLESALE_ONLY, Enum::RETAIL_WHOLESALE];
$merIds = Merchant::whereIn('wholesale', $saleType)->column('mer_id');
$query->whereIn('P.mer_id', $merIds);
if ($where['sale_type'] == Enum::SALE_TYPE_WHOLESALE) {
$query->join('StoreProductAttrValue PAV','S.product_id = PAV.product_id', 'left')->where('PAV.wholesale_price', '>', 0);
}
})
->when(isset($where['product_ids']) && $where['product_ids'] !== '',function($query)use($where){
$query->whereIn('P.product_id',$where['product_ids']);
@ -112,6 +115,14 @@ class SpuDao extends BaseDao
$query->whereIn('P.mer_id',$merId);
})
->when(isset($where['mer_type']) && $where['mer_type'] !== '',function($query)use($where){
$merId = Merchant::where('type_id', 22)->value('mer_id');
if ($where['mer_type'] == 1) {
$query->where('P.mer_id', $merId);
} elseif ($where['mer_type'] == 2) {
$query->where('P.mer_id', '<>', $merId);
}
})
->when(isset($where['cate_pid']) && $where['cate_pid'], function ($query) use ($where) {
$storeCategoryRepository = app()->make(StoreCategoryRepository::class);
if (is_array($where['cate_pid'])) {

View File

@ -46,13 +46,14 @@ class StoreCartRepository extends BaseRepository
}
/**
* @param $uid
* @param $user
* @param int $saleType
* @return array
* @author Qinii
*/
public function getList($user)
public function getList($user, int $saleType = 1)
{
$res = $this->dao->getAll($user->uid)->append(['checkCartProduct', 'UserPayCount', 'ActiveSku','spu']);
$res = $this->dao->getAll($user->uid, $saleType)->append(['checkCartProduct', 'UserPayCount', 'ActiveSku','spu']);
return $this->checkCartList($res, $user->uid, $user);
}

View File

@ -406,6 +406,7 @@ class StoreRefundOrderRepository extends BaseRepository
$data['order_id'] = $orderId;
$data['uid'] = $uid;
$data['mer_id'] = $order->mer_id;
$data['sale_type'] = $order['sale_type'];
$data['refund_order_sn'] = app()->make(StoreOrderRepository::class)->getNewOrderId(StoreOrderRepository::TYPE_SN_REFUND);
$refund_order_id = 0;
foreach ($products as $product) {
@ -605,6 +606,7 @@ class StoreRefundOrderRepository extends BaseRepository
$data['integral'] = $totalIntegral;
$data['platform_refund_price'] = $totalPlatformRefundPrice;
$data['refund_postage'] = $totalPostage;
$data['sale_type'] = $order['sale_type'];
return Db::transaction(function () use ($refundProduct, $data, $products, $order, &$refund_order_id) {
event('refund.creates.before', compact('data'));
@ -707,6 +709,7 @@ class StoreRefundOrderRepository extends BaseRepository
$data['refund_num'] = $num;
$data['extension_one'] = $total_extension_one;
$data['extension_two'] = $total_extension_two;
$data['sale_type'] = $order['sale_type'];
return Db::transaction(function () use ($order, $data, $product, $productId, $num) {
event('refund.create.before', compact('data'));

View File

@ -34,7 +34,7 @@ class SpuRepository extends BaseRepository
{
public $dao;
public $merchantFiled = 'mer_id,mer_name,mer_avatar,is_trader,mer_info,mer_keyword,type_id';
public $productFiled = 'P.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,S.ot_price,svip_price_type,stock,mer_svip_status';
public $productFiled = 'P.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,P.sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,S.ot_price,svip_price_type,P.stock,mer_svip_status';
public function __construct(SpuDao $dao)
{
$this->dao = $dao;

View File

@ -56,7 +56,8 @@ class StoreCart extends BaseController
*/
public function lst()
{
$data = $this->repository->getList($this->request->userInfo());
$saleType = $this->request->get('sale_type', 1);
$data = $this->repository->getList($this->request->userInfo(), intval($saleType));
return app('json')->success($data);
}
@ -172,7 +173,8 @@ class StoreCart extends BaseController
*/
public function cartCount()
{
return app('json')->success($this->repository->getCartCount($this->request->uid()));
$saleType = $this->request->get('sale_type', 1);
return app('json')->success($this->repository->getCartCount($this->request->uid()), intval($saleType));
}
/**

View File

@ -67,6 +67,7 @@ class StoreSpu extends BaseController
'type_code',
'category_id',
'label_name',
'mer_type',
]);
if ($where['type_id'] || $where['type_code']) {
$query = Merchant::where(['status' => 1, 'mer_state' => 1, 'is_del' => 0]);

View File

@ -553,9 +553,10 @@ class User extends BaseController
public function merchantRecord()
{
[$page, $limit] = $this->getPage();
$userIds = UserModel::where('spread_uid', $this->user->uid)->page($page, $limit)->column('uid');
$query = Merchant::whereIn('uid', $userIds)->where('is_del', 0);
$merchants = $query->page($page, $limit)
$userQuery = UserModel::where('spread_uid', $this->user->uid);
$count = $userQuery->count();
$userIds = $userQuery->page($page, $limit)->column('uid');
$merchants = Merchant::whereIn('uid', $userIds)->where('is_del', 0)
->field('mer_id,mer_name,uid,real_name,sale_amount,purchase_amount as buy_amount')
->select()->toArray();
$merchants = reset_index($merchants, 'uid');
@ -569,7 +570,7 @@ class User extends BaseController
$result[] = ['mer_id' => '', 'mer_name' => '', 'uid' => $userId, 'real_name' => '', 'sale_amount' => '0.00', 'buy_amount' => '0.00', 'status' => 0];
}
}
return app('json')->success(['count' => count($userIds), 'list' => $result]);
return app('json')->success(['count' => $count, 'list' => $result]);
}
/**