调整活动专区商品
This commit is contained in:
parent
90f055abd8
commit
3911709d32
@ -42,6 +42,7 @@ class StoreActivityDao extends BaseDao
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 活动商品专区
|
* 活动商品专区
|
||||||
|
* @param $userId
|
||||||
* @param $location
|
* @param $location
|
||||||
* @param $streetCode
|
* @param $streetCode
|
||||||
* @param $activityId
|
* @param $activityId
|
||||||
@ -50,7 +51,7 @@ class StoreActivityDao extends BaseDao
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function product($location, $streetCode, $activityId)
|
public function product($userId, $location, $streetCode, $activityId)
|
||||||
{
|
{
|
||||||
[$lat, $lng] = (new CityAreaDao())->getLngAndLat($location, $streetCode);
|
[$lat, $lng] = (new CityAreaDao())->getLngAndLat($location, $streetCode);
|
||||||
$cloud_product_arr = (new CloudProductDao())->getByDistance($lat, $lng, ['activity_id' => $activityId], 4);
|
$cloud_product_arr = (new CloudProductDao())->getByDistance($lat, $lng, ['activity_id' => $activityId], 4);
|
||||||
@ -69,17 +70,19 @@ class StoreActivityDao extends BaseDao
|
|||||||
if (!$cloud_product) {
|
if (!$cloud_product) {
|
||||||
return app('json')->success(['count' => 0, 'list' => []]);
|
return app('json')->success(['count' => 0, 'list' => []]);
|
||||||
}
|
}
|
||||||
$query = Db::name('cloud_product')->where('status', 1);
|
|
||||||
$count = $query->where(function($query){
|
|
||||||
$query->whereOr('mer_labels', '')
|
|
||||||
->whereOr('mer_labels',',5,');
|
|
||||||
})->count();
|
|
||||||
/** @var SpuRepository $spuRep */
|
/** @var SpuRepository $spuRep */
|
||||||
$spuRep = app()->make(SpuRepository::class);
|
$spuRep = app()->make(SpuRepository::class);
|
||||||
$products = $spuRep->getApiSearch($where, 1, 4, false, true);
|
$products = $spuRep->getApiSearch($where, 1, 4, false, true);
|
||||||
|
$canBuy = 1;
|
||||||
if ($products['list']) {
|
if ($products['list']) {
|
||||||
$list = $products['list'];
|
$list = $products['list'];
|
||||||
foreach ($cloud_product_arr as $key => $value) {
|
foreach ($cloud_product_arr as $key => $value) {
|
||||||
|
if (!empty($userId)) {
|
||||||
|
$buyRecord = $this->canBuy($userId, $value['product_id']);
|
||||||
|
if (!$buyRecord['is_true']) {
|
||||||
|
$canBuy = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach ($list as $k => $v) {
|
foreach ($list as $k => $v) {
|
||||||
if ($value['product_id'] == $v['product_id']) {
|
if ($value['product_id'] == $v['product_id']) {
|
||||||
if ($value['mer_labels'] == ',5,') {
|
if ($value['mer_labels'] == ',5,') {
|
||||||
@ -91,7 +94,7 @@ class StoreActivityDao extends BaseDao
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ['count' => $count, 'list' => $list ?? []];
|
return ['can_buy' => $canBuy, 'count' => $products['count'], 'list' => $list ?? []];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,10 +110,11 @@ class StoreActivity extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function product(StoreActivityDao $dao)
|
public function product(StoreActivityDao $dao)
|
||||||
{
|
{
|
||||||
|
$userId = $this->request->uid();
|
||||||
$location = $this->request->get('location');
|
$location = $this->request->get('location');
|
||||||
$streetCode = $this->request->get('street_code');
|
$streetCode = $this->request->get('street_code');
|
||||||
$activityId = $this->request->get('activity_id', 2);
|
$activityId = $this->request->get('activity_id', 2);
|
||||||
$result = $dao->product($location, $streetCode, $activityId);
|
$result = $dao->product($userId, $location, $streetCode, $activityId);
|
||||||
return app('json')->success($result);
|
return app('json')->success($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,6 +467,7 @@ Route::group('api/', function () {
|
|||||||
Route::post('receive', 'api.store.StoreActivity/receive'); //领取活动红包
|
Route::post('receive', 'api.store.StoreActivity/receive'); //领取活动红包
|
||||||
Route::get('record', 'api.store.StoreActivity/record'); //活动红包获取记录
|
Route::get('record', 'api.store.StoreActivity/record'); //活动红包获取记录
|
||||||
Route::get('total', 'api.store.StoreActivity/total'); //活动红包统计
|
Route::get('total', 'api.store.StoreActivity/total'); //活动红包统计
|
||||||
|
Route::get('product', 'api.store.StoreActivity/product'); //活动商品专区
|
||||||
});
|
});
|
||||||
})->middleware(UserTokenMiddleware::class, true);
|
})->middleware(UserTokenMiddleware::class, true);
|
||||||
|
|
||||||
@ -647,7 +648,6 @@ Route::group('api/', function () {
|
|||||||
Route::resource('store/product/cloudWarehouse', 'api.store.product.CloudWarehouse');
|
Route::resource('store/product/cloudWarehouse', 'api.store.product.CloudWarehouse');
|
||||||
Route::get('store/product/town_cloud', 'api.store.product.CloudWarehouse/town');
|
Route::get('store/product/town_cloud', 'api.store.product.CloudWarehouse/town');
|
||||||
Route::get('storeActivity/consumption', 'api.store.StoreActivity/consumption'); //消费金列表
|
Route::get('storeActivity/consumption', 'api.store.StoreActivity/consumption'); //消费金列表
|
||||||
Route::get('storeActivity/product', 'api.store.StoreActivity/product'); //活动商品专区
|
|
||||||
Route::post('open/activityCommission', 'api.open/activityCommission'); //活动佣金回调
|
Route::post('open/activityCommission', 'api.open/activityCommission'); //活动佣金回调
|
||||||
})->middleware(UserTokenMiddleware::class, false);
|
})->middleware(UserTokenMiddleware::class, false);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user