Merge branch 'profit_sharing' into dev

This commit is contained in:
luofei 2023-05-24 17:17:58 +08:00
commit 6f5ccbc6b5
7 changed files with 48 additions and 4 deletions

View File

@ -27,6 +27,8 @@ use think\model\Relation;
class StoreCartDao extends BaseDao
{
const SOURCE_CLOUD = 101; //店铺云商品
protected function getModel(): string
{
return StoreCart::class;

View File

@ -2,6 +2,7 @@
namespace app\common\repositories\store\order;
use app\common\dao\store\order\StoreCartDao;
use app\common\repositories\store\coupon\StoreCouponRepository;
use app\common\repositories\store\coupon\StoreCouponUserRepository;
use app\common\repositories\store\product\ProductAssistSkuRepository;

View File

@ -18,6 +18,7 @@ use crmeb\jobs\SendSmsJob;
use crmeb\jobs\SyncProductTopJob;
use crmeb\services\CopyCommand;
use crmeb\services\RedisCacheService;
use Fastknife\Utils\AesUtils;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\Log;
@ -33,6 +34,9 @@ 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.bar_code,S.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,P.ot_price,svip_price_type,stock,mer_svip_status';
public $userInfo;
public function __construct(SpuDao $dao)
{
$this->dao = $dao;
@ -162,6 +166,17 @@ class SpuRepository extends BaseRepository
{
$where['spu_status'] = 1;
$where['mer_status'] = 1;
if (!empty($where['keyword'])) {
if (preg_match('/^(\/@[1-9]{1}).*\*\//', $where['keyword'])) {
$command = app()->make(CopyCommand::class)->getMassage($where['keyword']);
if (!$command || in_array($command['type'], [30, 40])) return ['count' => 0, 'list' => []];
if ($this->userInfo && $command['uid']) app()->make(UserRepository::class)->bindSpread($this->userInfo, $command['uid']);
$where['spu_id'] = $command['id'];
unset($where['keyword']);
} else {
app()->make(UserVisitRepository::class)->searchProduct($this->userInfo ? $this->userInfo['uid'] : 0, $where['keyword'], (int)($where['mer_id'] ?? 0));
}
}
if ($rand) {
$RedisCacheService = app()->make(RedisCacheService::class);
$exists=$RedisCacheService->exists('CloudMerchantSpu'.$where['mer_id']);
@ -174,6 +189,8 @@ class SpuRepository extends BaseRepository
}
unset($where['mer_id']);
}
$entryMerId = $where['entry_mer_id'] ?? '';
unset($where['entry_mer_id']);
$query = $this->dao->search($where);
$count = $query->count();
@ -188,6 +205,9 @@ class SpuRepository extends BaseRepository
$list->append($append);
$list = $this->getBorderList($list);
foreach ($list as &$item) {
$item['referer'] = AesUtils::encrypt($entryMerId . '|' . time(), config('app.app_secret'));
}
return compact('count', 'list');
}
public function getBorderList($list)

View File

@ -12,6 +12,7 @@
namespace app\controller\api\store\order;
use app\common\dao\store\order\StoreCartDao;
use app\common\repositories\store\order\StoreOrderRepository;
use app\common\repositories\store\product\ProductAssistRepository;
use app\common\repositories\store\product\ProductAssistSetRepository;
@ -23,6 +24,7 @@ use app\common\repositories\store\product\StoreDiscountProductRepository;
use app\common\repositories\store\product\StoreDiscountRepository;
use app\common\repositories\store\StoreSeckillActiveRepository;
use app\common\repositories\user\UserRepository;
use Fastknife\Utils\AesUtils;
use MongoDB\BSON\MaxKey;
use think\App;
use crmeb\basic\BaseController;
@ -67,6 +69,11 @@ class StoreCart extends BaseController
public function create(validate $validate)
{
$data = $this->checkParams($validate);
if (!empty($data['referer'])) {
$decrypt = AesUtils::decrypt($data['referer'], config('app.app_secret'));
$decryptArray = explode('|', $decrypt);
}
$entryMerId = $decryptArray[0] ?? '';
if(!in_array($data['product_type'],[0,1,2,3,4,98])) return app('json')->fail('商品类型错误');
if ($data['cart_num'] <= 0) return app('json')->fail('购买数量有误');
$user = $this->request->userInfo();
@ -109,11 +116,19 @@ class StoreCart extends BaseController
//更新购物车
$cart_id = $cart['cart_id'];
$cart_num = ['cart_num' => ($cart['cart_num'] + $data['cart_num'])];
if ($entryMerId) {
$cart_num['source_id'] = $entryMerId;
$cart_num['source'] = StoreCartDao::SOURCE_CLOUD;
}
$storeCart = $this->repository->update($cart_id,$cart_num);
} else {
//添加购物车
$data['uid'] = $this->request->uid();
$data['mer_id'] = $result['product']['mer_id'];
if ($entryMerId) {
$data['source_id'] = $entryMerId;
$data['source'] = StoreCartDao::SOURCE_CLOUD;
}
$cart = $storeCart = $this->repository->create($data);
}
event('user.cart', compact('user','storeCart'));
@ -229,7 +244,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], 'referer']);
$validate->check($data);
if ($data['spread_id']) {
if ($data['spread_id'] !== $this->request->userInfo()->uid){

View File

@ -36,6 +36,7 @@ class CloudWarehouse extends BaseController
$this->repository = $repository;
$this->merchantDao = $merchantDao;
$this->spuRepository = $spuRepository;
$this->spuRepository->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null;
}
/**
@ -44,7 +45,7 @@ class CloudWarehouse extends BaseController
*/
public function index()
{
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0]]);
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword']);
$search = [
'street_id' => $params['street_code'],
'type_id' => Merchant::TypeStore,
@ -55,6 +56,7 @@ class CloudWarehouse extends BaseController
if (empty($merchantIds)) {
return app('json')->success(['count' => 0, 'list' => []]);
}
$where['keyword'] = $params['keyword'];
$where['mer_ids'] = $merchantIds;
$where['product_type'] = $params['product_type'];
$where['is_gift_bag'] = 0;

View File

@ -10,6 +10,7 @@
// +----------------------------------------------------------------------
namespace app\controller\api\store\product;
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;
@ -101,13 +102,14 @@ class StoreSpu extends BaseController
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common'
]);
if ($where['action']) unset($where['product_type']);
// $category_id=Db::name('merchant')->where('mer_id',$id)->value('category_id');->where('category_id',$category_id)
$mer_id=Db::name('merchant')->where('mer_state',1)->where('status',1)->where('type_id',11)->value('mer_id');
$category_id=Db::name('merchant')->where('mer_id',$id)->value('category_id');
$mer_id=Db::name('merchant')->where('mer_state',1)->where('status',1)->where('category_id',$category_id)->where('type_id',Merchant::TypeCloudWarehouse)->value('mer_id');
if (!$mer_id){
return app('json')->success(['count'=>0,'list'=>[]]);
}
$where['mer_id'] = $mer_id;
$where['entry_mer_id'] = $id;
$where['is_gift_bag'] = 0;
$where['order'] = $where['order'] ? $where['order'] : 'sort';
$data = $this->repository->getApiCloudSearch($where, $page, $limit);

View File

@ -44,4 +44,6 @@ return [
'error_message' => '页面错误!请稍后再试~',
// 显示错误信息
'show_error_msg' => false,
//应用加解密秘钥
'app_secret' => '789XH80PTSb8pHjH',
];