Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
f04f5b96ff
28
app/common/Enum.php
Normal file
28
app/common/Enum.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
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 => '批发',
|
||||
];
|
||||
|
||||
}
|
@ -247,6 +247,9 @@ class StoreOrderDao extends BaseDao
|
||||
break;
|
||||
}
|
||||
})
|
||||
->when(isset($where['sale_type']) && $where['sale_type'] !== '', function ($query) use ($where) {
|
||||
$query->where('sale_type', $where['sale_type']);
|
||||
})
|
||||
->order('StoreOrder.create_time DESC');
|
||||
|
||||
return $query;
|
||||
|
@ -11,9 +11,12 @@
|
||||
namespace app\common\dao\store\product;
|
||||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\Enum;
|
||||
use app\common\model\store\product\ProductAttrValue;
|
||||
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 +71,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']);
|
||||
})
|
||||
@ -193,6 +201,18 @@ class SpuDao extends BaseDao
|
||||
else if ($where['hot_type'] == 'best') $query->where('P.is_best', 1);
|
||||
else if ($where['hot_type'] == 'good') $query->where('P.is_benefit', 1);
|
||||
})
|
||||
->when(isset($where['deduction_rate']) && $where['deduction_rate'] !== '', function($query) use ($where) {
|
||||
$maxRate = $where['deduction_rate'] == 25 ? 100 : $where['deduction_rate'] + 5;
|
||||
$productIds = ProductAttrValue::when(isset($where['mer_id']) && $where['mer_id'] !== '', function($query) use ($where) {
|
||||
$query->where('mer_id', $where['mer_id']);
|
||||
})->where('profit_rate', '>=', $where['deduction_rate'])
|
||||
->where('profit_rate', '<', $maxRate)
|
||||
->column('product_id');
|
||||
if (empty($productIds)) {
|
||||
$productIds = [0];
|
||||
}
|
||||
$query->whereIn('S.product_id', $productIds);
|
||||
})
|
||||
->when(isset($where['svip']) && $where['svip'] !== '',function($query)use($where){
|
||||
$query->where('svip_price_type','>',0)->where('mer_svip_status',1);
|
||||
})
|
||||
|
@ -14,6 +14,7 @@
|
||||
namespace app\common\model\store\order;
|
||||
|
||||
|
||||
use app\common\Enum;
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\community\Community;
|
||||
use app\common\model\store\product\ProductGroupUser;
|
||||
@ -201,4 +202,17 @@ class StoreOrder extends BaseModel
|
||||
{
|
||||
return StoreRefundOrder::where('order_id',$this->order_id)->where('status',3)->sum('refund_price');
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为批发
|
||||
* @param $wholesale
|
||||
* @param $merId
|
||||
* @param $saleType
|
||||
* @return bool
|
||||
*/
|
||||
public static function isWholesale($wholesale, $merId, $saleType)
|
||||
{
|
||||
return $wholesale >= 1 && $merId > 0 && $saleType == Enum::SALE_TYPE_WHOLESALE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -297,4 +297,14 @@ class Merchant extends BaseModel
|
||||
return $this->wholesale == 1;
|
||||
}
|
||||
|
||||
public function typeNames()
|
||||
{
|
||||
return $this->merchantType()->bind(['type_name']);
|
||||
}
|
||||
|
||||
public function streetNames()
|
||||
{
|
||||
return $this->hasOne(GeoStreet::class, 'street_code', 'street_id')->bind(['street_name']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace app\common\repositories\store\order;
|
||||
|
||||
use app\common\dao\store\coupon\StoreCouponUserDao;
|
||||
use app\common\Enum;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\product\ProductCate;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
@ -40,6 +41,9 @@ use think\facade\{Cache, Db, Queue};
|
||||
|
||||
class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
{
|
||||
|
||||
public $saleType = Enum::SALE_TYPE_RETAIL;
|
||||
|
||||
public function v2CartIdByOrderInfo($user, array $cartId, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, $createOrder = false)
|
||||
{
|
||||
$uid = $user->uid;
|
||||
@ -83,7 +87,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
// 循环计算每个店铺的订单数据
|
||||
foreach ($merchantCartList as &$merchantCart) {
|
||||
//用户关联了商户id且下单店铺支持批发
|
||||
$isWholeSale = $merchantCart['wholesale'] == 1 && $merId > 0;
|
||||
$isWholeSale = StoreOrder::isWholesale($merchantCart['wholesale'], $merId, $this->saleType);
|
||||
$postageRule = [];
|
||||
$total_price = 0;
|
||||
$total_num = 0;
|
||||
@ -129,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']);
|
||||
@ -901,7 +909,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'order_refund_switch',
|
||||
'order',
|
||||
'cartCoupon'
|
||||
) + ['allow_address' => !$allow_no_address, 'order_delivery_status' => $orderDeliveryStatus];
|
||||
) + ['allow_address' => !$allow_no_address, 'order_delivery_status' => $orderDeliveryStatus, 'sale_type' => $this->saleType];
|
||||
Cache::set('order_create_cache' . $uid . '_' . $key, $data, 600);
|
||||
return $data;
|
||||
}
|
||||
@ -1116,6 +1124,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'],
|
||||
];
|
||||
$allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']);
|
||||
$orderList[] = $_order;
|
||||
|
@ -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')) {
|
||||
@ -1661,6 +1664,7 @@ class ProductRepository extends BaseRepository
|
||||
'bar_code' => $value['bar_code'],
|
||||
];
|
||||
if ($this->isWholesale) {
|
||||
$_value['ot_price'] = $value['price'];
|
||||
$_value['price'] = $value['wholesale_price'];
|
||||
}
|
||||
if ($productType == 0) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
||||
use app\common\repositories\store\MerchantTakeRepository;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use app\common\repositories\store\product\ProductCopyRepository;
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
@ -283,7 +284,7 @@ class MerchantRepository extends BaseRepository
|
||||
*/
|
||||
public function getList($where, $page, $limit, $userInfo)
|
||||
{
|
||||
$field = 'care_count,is_trader,type_id,mer_id,mer_banner,mini_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,is_best,create_time,long,lat,is_margin';
|
||||
$field = 'care_count,is_trader,type_id,mer_id,mer_banner,mini_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,is_best,create_time,long,lat,is_margin,mer_address,street_id,service_phone,mer_info';
|
||||
$where['status'] = 1;
|
||||
$where['mer_state'] = 1;
|
||||
$where['is_del'] = 0;
|
||||
@ -305,8 +306,10 @@ class MerchantRepository extends BaseRepository
|
||||
$query = $this->dao->search($where)->with(['type_name']);
|
||||
$count = $query->count();
|
||||
$status = systemConfig('mer_location') && isset($where['location']);
|
||||
$list = $query->page($page, $limit)->setOption('field', [])->field($field)->select()
|
||||
->each(function ($item) use ($status, $where) {
|
||||
/** @var MerchantTakeRepository $repository */
|
||||
$repository = app()->make(MerchantTakeRepository::class);
|
||||
$list = $query->with(['streetNames','typeNames'])->page($page, $limit)->setOption('field', [])->field($field)->select()
|
||||
->each(function ($item) use ($status, $where, $repository) {
|
||||
if ($status && $item['lat'] && $item['long'] && isset($where['location']['lat'], $where['location']['long'])) {
|
||||
$distance = getDistance($where['location']['lat'], $where['location']['long'], $item['lat'], $item['long']);
|
||||
if ($distance < 0.9) {
|
||||
@ -319,7 +322,18 @@ class MerchantRepository extends BaseRepository
|
||||
}
|
||||
$item['distance'] = $distance;
|
||||
}
|
||||
$item['recommend'] = isset($where['delivery_way']) ? $item['CityRecommend'] : $item['AllRecommend'];
|
||||
$delivery = $repository->get($item['mer_id']) + systemConfig(['tx_map_key']);
|
||||
$item['mer_certificate'] = merchantConfig($item['mer_id'], 'mer_certificate');
|
||||
if (empty($item['mer_certificate'][0])) {
|
||||
$item['mer_certificate'] = [];
|
||||
}
|
||||
$item['mer_take_time'] = $delivery['mer_take_time'];
|
||||
// if(isset($where['type_id'])&& $where['type_id']==12){
|
||||
// $item['recommend'] = $item['AllRecommendType'];
|
||||
// }else{
|
||||
// $item['recommend'] = isset($where['delivery_way']) ? $item['CityRecommend'] : $item['AllRecommend'];
|
||||
//
|
||||
// }
|
||||
return $item;
|
||||
});
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
namespace app\controller\api\store\merchant;
|
||||
|
||||
use app\common\repositories\store\service\StoreServiceRepository;
|
||||
use app\common\model\system\merchant\MerchantType;
|
||||
use app\common\repositories\user\UserMerchantRepository;
|
||||
use think\App;
|
||||
use crmeb\basic\BaseController;
|
||||
@ -43,7 +43,14 @@ class Merchant extends BaseController
|
||||
public function lst()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id','is_trader']);
|
||||
$where = $this->request->params(['merchant_category_id', 'keyword', 'order', 'is_best', 'location', 'category_id', 'type_id', 'type_code', 'is_trader', 'street_id']);
|
||||
if (empty($where['type_id'])) {
|
||||
$where['type_id'] = MerchantType::where('is_allow_apply', 1)->where('is_search_display', 1)->column('mer_type_id');
|
||||
}
|
||||
if ($where['merchant_category_id'] > 0) {
|
||||
$where['category_id'] = $where['merchant_category_id'];
|
||||
unset($where['merchant_category_id']);
|
||||
}
|
||||
return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ class StoreCart extends BaseController
|
||||
*/
|
||||
public function checkParams(validate $validate)
|
||||
{
|
||||
$data = $this->request->params(['product_id','product_attr_unique','cart_num','is_new',['product_type',0],['group_buying_id',0],['spread_id',0]]);
|
||||
$data = $this->request->params(['product_id','product_attr_unique','cart_num','is_new',['product_type',0],['group_buying_id',0],['spread_id',0], ['sale_type',1]]);
|
||||
$validate->check($data);
|
||||
if ($data['spread_id']) {
|
||||
if ($data['spread_id'] !== $this->request->userInfo()->uid){
|
||||
|
@ -63,6 +63,7 @@ class StoreOrder extends BaseController
|
||||
$uid = $user->uid;
|
||||
if (!($count = count($cartId)) || $count != count($cartRepository->validIntersection($cartId, $uid)))
|
||||
return app('json')->fail('数据无效');
|
||||
$orderCreateRepository->saleType = (int)$this->request->param('sale_type', 1);
|
||||
$orderInfo = $orderCreateRepository->v2CartIdByOrderInfo($user, $cartId, $takes, $couponIds, $useIntegral, $addressId);
|
||||
|
||||
return app('json')->success($orderInfo);
|
||||
@ -137,6 +138,7 @@ class StoreOrder extends BaseController
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where['status'] = $this->request->param('status');
|
||||
$where['search'] = $this->request->param('store_name');
|
||||
$where['sale_type'] = $this->request->param('sale_type', 1);
|
||||
$where['uid'] = $this->request->uid();
|
||||
$where['paid'] = 1;
|
||||
// $where['is_user'] = 1;
|
||||
|
@ -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);
|
||||
|
@ -11,11 +11,13 @@
|
||||
namespace app\controller\api\store\product;
|
||||
|
||||
use app\common\model\store\product\ProductLabel;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
use app\common\repositories\store\StoreCategoryRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use app\common\repositories\user\UserHistoryRepository;
|
||||
use app\common\repositories\user\UserVisitRepository;
|
||||
use app\controller\admin\system\merchant\MerchantType;
|
||||
use crmeb\services\CopyCommand;
|
||||
use think\App;
|
||||
use crmeb\basic\BaseController;
|
||||
@ -61,8 +63,24 @@ class StoreSpu extends BaseController
|
||||
'filter_params',
|
||||
'mer_type_id',
|
||||
'sys_labels',
|
||||
'deduction_rate'
|
||||
'deduction_rate',
|
||||
'sale_type',
|
||||
'type_id',
|
||||
'type_code',
|
||||
'category_id',
|
||||
]);
|
||||
if ($where['type_id'] || $where['type_code']) {
|
||||
$query = Merchant::where(['status' => 1, 'mer_state' => 1, 'is_del' => 0]);
|
||||
$mer_type_id = MerchantType::where('type_code', $where['type_code'])->value('mer_type_id');
|
||||
if ($mer_type_id && $where['type_code'] == 'PersonalStore') {
|
||||
$where['mer_ids'] = $query->where('type_id', $mer_type_id)->column('mer_id');
|
||||
} else {
|
||||
$where['mer_ids'] = $query->whereIn('type_id', explode(',', $where['type_id']))->column('mer_id');
|
||||
}
|
||||
}
|
||||
if ($where['category_id'] != '') {
|
||||
$where['mer_ids'] = Merchant::where(['category_id' => $where['category_id'], 'status' => 1, 'is_del' => 0])->column('mer_id');
|
||||
}
|
||||
$where['is_gift_bag'] = 0;
|
||||
$where['product_type'] = 0;
|
||||
$where['order'] = $where['order'] ?: 'star';
|
||||
@ -101,7 +119,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:用户收藏
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
.card_container[data-v-3cdac0fe]{margin-top:150px;text-align:center}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
.el-dropdown-link[data-v-1f044121]{cursor:pointer;color:var(--prev-color-primary);font-size:12px}.el-icon-arrow-down[data-v-1f044121]{font-size:12px}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user