调整活动商品区域查询
This commit is contained in:
parent
340fdea8bb
commit
1c138a6ff8
@ -19,6 +19,7 @@ use app\common\model\store\product\CloudProduct;
|
|||||||
use app\common\model\store\StoreActivity;
|
use app\common\model\store\StoreActivity;
|
||||||
use app\common\model\store\StoreActivityOrderProduct;
|
use app\common\model\store\StoreActivityOrderProduct;
|
||||||
use app\common\repositories\store\product\SpuRepository;
|
use app\common\repositories\store\product\SpuRepository;
|
||||||
|
use think\db\Query;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
@ -139,4 +140,27 @@ class StoreActivityDao extends BaseDao
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据活动获取对应的镇街
|
||||||
|
* @param $activityId
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function district($activityId)
|
||||||
|
{
|
||||||
|
$merchants = CloudProduct::with(['merchant' => function (Query $query) {
|
||||||
|
$query->with(['street' => function (Query $query) {
|
||||||
|
$query->field('street_code,street_name');
|
||||||
|
}])->field('mer_id,street_id');
|
||||||
|
}])->where('activity_id', $activityId)->field('mer_id')->group('mer_id')->select()->toArray();
|
||||||
|
$result = [];
|
||||||
|
foreach ($merchants as $merchant) {
|
||||||
|
$streetCode = $merchant['merchant']['street']['street_code'] ?? '';
|
||||||
|
$streetName = $merchant['merchant']['street']['street_name'] ?? '';
|
||||||
|
if (!isset($result[$streetCode]) && !empty($streetCode)) {
|
||||||
|
$result[$streetCode] = ['street_code' => $streetCode, 'street_name' => $streetName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array_values($result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
namespace app\common\model\store\product;
|
namespace app\common\model\store\product;
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\system\merchant\Merchant;
|
||||||
|
|
||||||
class CloudProduct extends BaseModel
|
class CloudProduct extends BaseModel
|
||||||
{
|
{
|
||||||
@ -30,4 +31,9 @@ class CloudProduct extends BaseModel
|
|||||||
return 'cloud_product';
|
return 'cloud_product';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function merchant()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Merchant::class, 'mer_id', 'mer_id');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -310,4 +310,10 @@ class Merchant extends BaseModel
|
|||||||
{
|
{
|
||||||
$query->whereIn('mer_id',$value);
|
$query->whereIn('mer_id',$value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function street()
|
||||||
|
{
|
||||||
|
return $this->hasOne(GeoStreet::class, 'street_code', 'street_id');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -118,4 +118,16 @@ class StoreActivity extends BaseController
|
|||||||
return app('json')->success($result);
|
return app('json')->success($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据活动获取对应的镇街
|
||||||
|
* @param StoreActivityDao $dao
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function district(StoreActivityDao $dao)
|
||||||
|
{
|
||||||
|
$activityId = $this->request->get('activity_id', 2);
|
||||||
|
$result = $dao->district($activityId);
|
||||||
|
return app('json')->success($result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -468,6 +468,7 @@ Route::group('api/', function () {
|
|||||||
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'); //活动商品专区
|
Route::get('product', 'api.store.StoreActivity/product'); //活动商品专区
|
||||||
|
Route::get('district', 'api.store.StoreActivity/district'); //活动地区列表
|
||||||
});
|
});
|
||||||
})->middleware(UserTokenMiddleware::class, true);
|
})->middleware(UserTokenMiddleware::class, true);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user