店铺云商品下单记录入口店铺信息

This commit is contained in:
luofei 2023-05-24 16:26:43 +08:00
parent 0129bdb573
commit caee99f429
5 changed files with 27 additions and 1 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;
@ -1324,6 +1325,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
'integral' => $cart['integral'] ? bcdiv($cart['integral']['use'], $cart['cart_num'], 0) : 0,
'integral_total' => $cart['integral'] ? $cart['integral']['use'] : 0,
'product_type' => $cart['product_type'],
'source_mer_id' => $cart['source'] == StoreCartDao::SOURCE_CLOUD ? $cart['source_id'] : 0,
'cart_info' => json_encode($order_cart)
];
}

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;
@ -174,6 +175,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 +191,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

@ -109,6 +109,7 @@ class StoreSpu extends BaseController
}
$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);