调整商品列表

This commit is contained in:
luofei 2024-03-13 17:06:26 +08:00
parent 2950b863a9
commit 56e0af48df
7 changed files with 30 additions and 4 deletions

View File

@ -2,14 +2,24 @@
namespace app\common;
/**
* 枚举类
*/
class Enum
{
/** 购物车、订单相关 */
const SALE_TYPE_RETAIL = 1; //零售类型
const SALE_TYPE_WHOLESALE = 2; //批发类型
/** 通用状态 */
const STATUS_ENABLE = 1; //允许状态
const STATUS_DISABLE = 0; //禁用状态
/** 店铺相关 */
const RETAIL_ONLY = 0; //仅零售
const WHOLESALE_ONLY = 1; //仅批发
const RETAIL_WHOLESALE = 2; //零售和批发
/** @const MAP */
const MAP = [
self::SALE_TYPE_RETAIL => '零售',
self::SALE_TYPE_WHOLESALE => '批发',

View File

@ -11,9 +11,11 @@
namespace app\common\dao\store\product;
use app\common\dao\BaseDao;
use app\common\Enum;
use app\common\model\store\product\ProductCate;
use app\common\model\store\product\Spu;
use app\common\model\store\StoreCategory;
use app\common\model\system\merchant\Merchant;
use app\common\repositories\store\StoreCategoryRepository;
use app\common\repositories\system\merchant\MerchantRepository;
use crmeb\services\VicWordService;
@ -68,6 +70,11 @@ class SpuDao extends BaseDao
->when(isset($where['mer_ids']) && $where['mer_ids'] !== '',function($query)use($where){
$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];
$merIds = Merchant::whereIn('wholesale', $saleType)->column('mer_id');
$query->whereIn('P.mer_id', $merIds);
})
->when(isset($where['product_ids']) && $where['product_ids'] !== '',function($query)use($where){
$query->whereIn('P.product_id',$where['product_ids']);
})

View File

@ -133,6 +133,10 @@ class StoreOrderCreateRepository extends StoreOrderRepository
}
foreach ($merchantCart['list'] as $k => $cart) {
if ($isWholeSale) {
$merchantCart['list'][$k]['productAttr']['price'] = $cart['productAttr']['wholesale_price'];
$merchantCart['list'][$k]['product']['price'] = $cart['productAttr']['wholesale_price'];
}
//获取订单商品支持的配送类型
if ($cart['product']['delivery_way']) {
$delivery_way = explode(',', $cart['product']['delivery_way']);

View File

@ -12,6 +12,7 @@
namespace app\common\repositories\store\product;
use app\common\model\store\order\StoreOrder;
use app\common\model\store\product\ProductLabel;
use app\common\model\user\User;
use app\common\repositories\community\CommunityRepository;
@ -61,6 +62,8 @@ class ProductRepository extends BaseRepository
/** @var $isWholesale bool 是否批发 */
public $isWholesale = false;
/** @var $saleType int 售卖类型 */
public $saleType;
protected $dao;
const CREATE_PARAMS = [
"is_copy", "image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "unit_name", "sort", "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free', 'param_temp_id', 'extend', 'mer_form_id',
@ -1379,7 +1382,7 @@ class ProductRepository extends BaseRepository
],
$userInfo['uid']
);
$this->isWholesale = $product->merchant->isWholesale() && $userInfo->getMerId() > 0;
$this->isWholesale = StoreOrder::isWholesale($product->merchant['wholesale'], $userInfo->getMerId(), $this->saleType);
}
if (systemConfig('sys_reply_status')) {

View File

@ -114,7 +114,7 @@ class MerchantCategoryRepository extends BaseRepository
*/
public function getSelect()
{
$query = $this->search([])->field('merchant_category_id,category_name');
$query = $this->search([])->field('merchant_category_id,category_name,background');
$list = $query->select()->toArray();
return $list;
}

View File

@ -67,6 +67,7 @@ class StoreProduct extends BaseController
*/
public function detail($id)
{
$this->repository->saleType = $this->request->get('sale_type', 1);
$data = $this->repository->detail((int)$id, $this->userInfo);
if (!$data) {
app()->make(SpuRepository::class)->changeStatus($id, 0);

View File

@ -61,7 +61,8 @@ class StoreSpu extends BaseController
'filter_params',
'mer_type_id',
'sys_labels',
'deduction_rate'
'deduction_rate',
'sale_type',
]);
$where['is_gift_bag'] = 0;
$where['product_type'] = 0;
@ -101,7 +102,7 @@ class StoreSpu extends BaseController
public function recommend()
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['common','mer_id']);
$where = $this->request->params(['common', 'mer_id', 'sale_type']);
$where['is_gift_bag'] = 0;
//1:星级
//2:用户收藏