| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587 |
- <?php
- namespace addons\Store\api\modules\v1\controllers;
- use addons\Coupon\common\enums\AddonsCouponEnum;
- use addons\Coupon\common\models\AddonsCoupon;
- use addons\Coupon\common\models\AddonsCouponUserRelate;
- use addons\Coupon\common\models\CouponStoreGoodsRelate;
- use addons\ReservationService\common\models\ReservationServiceStoreGoods;
- use addons\Store\common\enums\StoreEnum;
- use addons\Store\common\logic\store\StoreEntryLimit;
- use addons\Store\common\models\Store;
- use addons\Store\common\models\StoreCate;
- use addons\Store\common\models\StoreClerk;
- use addons\Store\common\models\StoreClerkLog;
- use addons\Store\common\models\StoreCollect;
- use addons\Store\common\models\StoreCoupon;
- use addons\Store\common\models\StoreCouponCatRelate;
- use addons\Store\common\models\StoreCouponGoodsRelate;
- use addons\Store\common\models\StoreCouponShareLog;
- use addons\Store\common\models\StoreCouponUserRelate;
- use addons\Store\common\models\StoreGoods;
- use addons\Store\common\models\StoreGoodsCate;
- use addons\Store\common\models\StoreMiniCode;
- use addons\Store\common\models\StoreNotice;
- use addons\Store\common\services\StoreOrderService;
- use addons\Store\common\services\StoreReserveSettingService;
- use addons\Store\common\services\StoreService;
- use addons\Store\common\services\StoreSettingService;
- use addons\Store\common\services\StoreAssociatedUserService;
- use addons\TeamLeader\common\models\UserPartitionRelationship;
- use common\enums\AddonsEnum;
- use common\enums\StatusEnum;
- use common\models\common\Region;
- use common\models\mall\MallAddons;
- use common\models\order\Order;
- use common\models\order\OrderComments;
- use common\models\user\User;
- use Yii;
- use api\controllers\OnAuthController;
- use common\helpers\DebrisHelper;
- use common\models\common\AddonsMarketingSetting;
- use common\enums\OrderStatusEnum;
- use common\enums\ShippingTypeEnum;
- use addons\Store\common\services\StoreTrackingService;
- /**
- * 默认控制器
- *
- * Class DefaultController
- * @package addons\Store\api\modules\v1\controllers
- */
- class StoreController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = ['index','get-content-by-code','store-list', 'store-more'];
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- date_default_timezone_set('PRC');
- $params = Yii::$app->request->get();
- $store_id = $params['store_id'];
- if (empty($store_id)) {
- return $this->error('参数错误');
- }
- $mall_id = $this->mall_id;
- $store = Store::getOne([['id' => $store_id], ['mall_id' => $mall_id]]);
- if (empty($store)) return $this->error('店铺打烊了');
- if(empty($store['status'])) return $this->error('该门店已下架');
- $data['store_status'] = StoreService::checkBusinessTime($store, 'front') ?? '';
- // $virtual_sales = StoreGoods::find()->where(['mall_id'=>$mall_id,'store_id'=>$store_id, 'status' => StatusEnum::ENABLED])->sum('virtual_sales');
- $data['store_id'] = $store['id'];
- $data['bannar_pic'] = !empty($store['bannar_pic'])?json_decode($store['bannar_pic'],true):[];
- $data['introduce'] = !empty($store['introduce'])?json_decode($store['introduce'],true):[];
- $data['freight_type'] = !empty($store['freight_type'])?json_decode($store['freight_type'],true):[];
- $data['logo_img'] = $store['logo_img'];
- $data['store_img'] = $store['store_img'];
- $data['store_desc'] = $store['store_desc'];
- $data['store_name'] = $store['store_name'];
- $data['store_background'] = $store['store_background'];
- $data['store_background'] = $store['store_background'];
- $decoration = \Yii::$app->services->setting->addons->get($mall_id, StoreEnum::ADDONS_NAME, 'decoration');
- // 是否开启分类
- if(!empty($decoration['custom_store_style'])){
- $data['store_category_switch'] = $store['store_category_switch'] ?? 0;
- $data['store_style'] = $store['show_style']??1;
- $data['default_store_cate_style'] = $store['default_store_cate_style']??1;
- }else{
- $data['store_category_switch'] = $decoration['store_category_switch'] ?? 0;
- $data['store_style'] = $decoration['default_store_style']??1;
- $data['default_store_cate_style'] = $decoration['default_store_cate_style']??1;
- }
- $data['license_img'] = $store['license_img'];
- $store_score_deduction = (new StoreSettingService(['mall_id'=>$this->mall_id]))->getDeductionProportion(['store_id'=>[$store['id']]]);
- $data['store_score_deduction'] = $store_score_deduction[$store['id']]??[];
- $data['sales_volume'] = $store['sales_volume'];
- $data['latitude'] = $store['latitude'];
- $data['praise'] = $store['praise'];//好评
- $intra_city_distribution = json_decode($store['intra_city_distribution'], true);
- $data['distribution_fee'] = $intra_city_distribution['distribution_fee'] ?? 0;//配送费
- $notice_list = StoreNotice::lists(['where' => [['store_id' => $store_id], ['mall_id' => $mall_id], ['status' => StatusEnum::ENABLED]],
- 'order' => 'id desc', 'select' => 'id,title,content', 'limit' => 1]);
- $data['notice_list'] = $notice_list;
- $comment_where = [['store_id' => $store_id], ['mall_id' => $mall_id], ['status' => StatusEnum::ENABLED]];
- $order_comment_count = OrderComments::listCount(['where' => $comment_where,]);
- $data['order_comment_count'] = $order_comment_count ?? 0;//评论条数
- $store_goods_cate_list = StoreGoodsCate::lists([
- 'where' => [
- ['store_id' => $store_id],
- ['mall_id' => $mall_id],
- ['status' => StatusEnum::ENABLED],
- ['is_show' => 1],
- ],
- 'select' => 'id,name',
- 'order' => 'sort asc',
- ]);
- $data['store_goods_cate_list'] = $store_goods_cate_list;
- $store_goods_cate_list = StoreGoodsCate::lists([
- 'where' => [
- ['store_id' => $store_id],
- ['mall_id' => $mall_id],
- ['status' => StatusEnum::ENABLED],
- ['is_show' => 1],
- ['parent_id' => 0],
- ],
- 'with'=> ['child'=>function ($q) {
- $q->select('id,name,parent_id')->where(['status' => StatusEnum::ENABLED]);
- },'child.child'=>function ($q) {
- $q->select('id,name,parent_id')->where(['status' => StatusEnum::ENABLED]);
- }],
- 'select' => 'id,name,parent_id',
- 'order' => 'sort asc',
- ]);
- $data['store_goods_cate_list_unlimited'] = $store_goods_cate_list;
- $select = 'id,name,store_id,type,expire_type,expire_day,effect_days,begin_at,end_at,appoint_type,rule,discount_limit,sub_price,discount,min_price,coupon_status';
- $coupon_list = StoreCoupon::lists([
- 'where' => [
- ['store_id' => $store['id']],
- ['status' => StatusEnum::ENABLED],
- ['coupon_status' => AddonsCouponEnum::STATUS_RECEIVING],
- ],
- 'select' => $select,
- 'limit' => 6
- ]);
- $coupon_ids = array_column($coupon_list, 'id');
- $relate_list = StoreCouponUserRelate::lists(['where' => [['coupon_id' => $coupon_ids],['user_id'=>$this->user_id], ['from_type' => 2]], 'index' => 'coupon_id']);
- foreach ($coupon_list as &$item) {
- $item['is_receive'] = 0;
- if (isset($relate_list[$item['id']])) {
- $item['is_receive'] = 1;
- $item['is_use'] = $relate_list[$item['id']]['is_use'];
- }
- }
- $data['coupon_list'] = $coupon_list ?? [];
- $data['coupon_counts'] = count($data['coupon_list']);
- $data['shop_mobile'] = $store['shop_mobile'];
- $data['business_time_start'] = $store['business_time_start'];
- $data['business_time_end'] = $store['business_time_end'];
- $store_cate = StoreCate::findOne(['id' => $store['c_id']]);
- $data['store_cate_name'] = $store_cate['name'];
- $data['distance'] = 0;
- if (!empty($params['longitude']) && !empty($params['latitude'])) {
- // $distance = (new LocationHelper())->getDistanceByGeo($params['latitude'], $params['longitude'], $store['latitude'], $store['longitude']);
- //为了和下面列表“actionStoreList()”输出的经纬度保持一致,所以使用新的方法来计算“自己和商家的距离”
- $distance = round(
- 2 * 6378.137 * ASIN(
- SQRT(
- POW(
- SIN(
- PI() * ($params['longitude'] - $store['longitude']) / 360
- ),
- 2
- ) + COS(PI() * $params['latitude'] / 180) * COS($store['latitude'] * PI() / 180) * POW(
- SIN(
- PI() * ($params['latitude'] - $store['latitude']) / 360
- ),
- 2
- )
- )
- )
- ,1);
- $data['distance'] = bcmul($distance, 1, 1);
- }
- $data['address'] = $store['address'];
- $data['longitude'] = $store['longitude'];
- $data['latitude'] = $store['latitude'];
- $recommend_goods_list = StoreGoods::getRecommendList($mall_id,$store_id);
- $data['recommend_goods_list'] = $recommend_goods_list;
- $store_collect = StoreCollect::getOne([['store_id'=>$store['id']],['user_id'=>$this->user_id],['status'=>StatusEnum::ENABLED]]);
- $data['is_collect'] = !empty($store_collect)?1:0;
- $data['share_title'] = $store['share_title'];
- $data['share_desc'] = $store['share_desc'];
- $data['share_pic'] = $store['share_pic'];
- $data['show_sync_goods'] = $store['show_sync_goods'];
- // 客服配置信息
- $data['customer'] = StoreService::getCustomer($mall_id, $store_id);
- // 判断是否安装智慧城市插件(此功能为智慧城市客服定制)
- $data['is_install_smart_city'] = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_SMART_CITY) ? StatusEnum::ENABLED : StatusEnum::DISABLED;
- // 是否显示技师列表
- $is_show_staff = 0;
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_RESERVATION_SERVICE)) {
- $is_show_staff = StatusEnum::ENABLED;
- $store_reserve_setting = (new StoreReserveSettingService(['mall_id' => $this->mall_id, 'store_id' => $store_id]))->detail();
- if (!empty($store_reserve_setting['employee_selection']) && $store_reserve_setting['employee_selection'] == 3) {
- $is_show_staff = 0;
- } else {
- $goods_ids = ReservationServiceStoreGoods::find()->where(['store_id' => $store, 'status' => StatusEnum::ENABLED])->select('goods_id')->column();
- $res = StoreGoods::find()->where(['id' => $goods_ids, 'store_id' => $store_id, 'mall_id' => $this->mall_id, 'check_status' => 1, 'is_on_sale' => 1, 'status' => StatusEnum::ENABLED])
- ->one();
- if (empty($res)) {
- $is_show_staff = 0;
- }
- }
- }
- $data['is_show_staff'] = $is_show_staff;
- //新增浏览记录
- $StoreTrackingService = new StoreTrackingService();
- $trackingData = [
- 'store_id' => $params['store_id'],
- 'mall_id' => $mall_id,
- 'user_id' => $this->user_id
- ];
- $StoreTrackingService->addStoreTracking($trackingData);
- return $this->success('成功', $data);
- }
- //店铺列表
- public function actionStoreList()
- {
- $params = Yii::$app->request->get();
- $longitude = $params['longitude'] ?? 0;//经度
- $latitude = $params['latitude'] ?? 0;//纬度
- $city_name = $params['city_name'] ?? '';
- if ($longitude && $latitude) {
- $page = $params['page'] ?? 1;
- $limit = $params['limit'] ?? 10;
- // 默认按距离排序
- $sort = empty($params['sort']) ? 'distance' : $params['sort'];
- if ($sort == 'comprehensive') $sort = 'distance';
- $mall_id = $this->mall_id;
- $status = StatusEnum::ENABLED;
- $shop_status = 1;
- $check_status = 1;
- $sql = " SELECT id,store_name,latitude,longitude,logo_img,sales_volume,praise,show_style,bannar_pic,address,is_show_coupon,default_store_cate_style,
- round(
- 2 * 6378.137 * ASIN(
- SQRT(
- POW(
- SIN(
- PI() * ({$longitude} - longitude) / 360
- ),
- 2
- ) + COS(PI() * {$latitude} / 180) * COS(latitude * PI() / 180) * POW(
- SIN(
- PI() * ({$latitude} - latitude) / 360
- ),
- 2
- )
- )
- )
- ,1) AS distance
- FROM `qimall_addons_store` WHERE (`mall_id`={$mall_id}) AND (`status`={$status}) AND (`shop_status`={$shop_status}) AND (`check_status`={$check_status})";
- $query = Store::find()->where(['mall_id' => $mall_id, 'status' => $status, 'shop_status' => $shop_status, 'check_status' => $check_status]);
- if (!empty($params['keyword'])) {
- $store_goods_list = StoreGoods::lists([
- 'where'=>[
- ['mall_id'=>$this->mall_id],
- ['check_status'=>1],
- ['is_on_sale'=>1],
- ['status'=>StatusEnum::ENABLED],
- ['like', 'goods_name', trim($params['keyword'])],
- ],
- 'select'=>'id,store_id,goods_name,price,original_price,cover_pic',
- 'order'=>'id desc',
- ]);
- $store_id_arr = array_column($store_goods_list,'store_id');
- $query->andWhere([
- 'or',
- ['like', 'store_name', trim($params['keyword'])],
- ['id'=>$store_id_arr]
- ]);
- $store_ids = join(',',$store_id_arr);
- if(empty($store_ids)) $store_ids = 0;
- $sql .= " and (
- store_name LIKE '%" . $params['keyword'] . "%' or id in ({$store_ids})
- )";
- }
- if (!empty($params['cate_id'])) {
- $query->andWhere(['c_id' => $params['cate_id']]);
- $cid_arr = StoreCate::find()->where(['parent_id'=>$params['cate_id'],'is_show'=>1,'status'=>1])->select('id')->column();
- $cid_arr = array_merge([$params['cate_id']],$cid_arr);
- $sql .= " and c_id in (" . implode(',',$cid_arr).')';
- }
- $setting = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'basic');
- // $is_show_location_store = $setting['is_show_location_store'] ?? 0;
- // if($is_show_location_store && $city_name){
- // $city_id = Region::find()->where(['name' => $city_name])->select('id')->scalar();
- // if(!empty($city_id)) {
- // $query->andWhere(['city_id' => $city_id]);
- // $sql .= " and city_id = " . $city_id;
- // }
- // }
- if(!empty($params['store_id'])){
- $query->andWhere(['id' => explode(',',$params['store_id'])]);
- $sql .= " and id in (" . $params['store_id'].')';
- }
- //获取门店配置
- $basic = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'basic');
- if ($basic['is_location_limit'] == 1) { //是否开启了限制距离按钮,开启则获取再限制距离内的门店
- $localtion_limit = $basic['localtion_limit'] ? $basic['localtion_limit'] : 10;
- $sql .= " having (`distance`<={$localtion_limit})";
- }
- if (in_array($sort, ['sales_volume', 'praise'])) {
- $sql .= " order by {$sort} desc";
- } else if ($sort == 'distance') {
- $sql .= " order by {$sort} asc";
- }
- // print_r($query);exit;
- // $count = $query->count();
- $count_list = \Yii::$app->db->createCommand($sql)->queryAll();
- $count = count($count_list);
- $sql .= " limit " . ($page - 1) * $limit . ",{$limit}";
- $list = \Yii::$app->db->createCommand($sql)->queryAll();
- if (!empty($list)) {
- $store_ids = array_column($list, 'id');
- // $order_comment_arr = OrderComments::lists(['where' => [['store_id' => $store_ids]], 'group' => 'store_id', 'order' => 'created_at desc', 'select' => 'store_id,content', 'index' => 'store_id']);
- $select = 'id,name,store_id,type,expire_type,expire_day,effect_days,begin_at,end_at,appoint_type,rule,discount_limit,sub_price,discount,min_price,coupon_status';
- $coupon_list = StoreCoupon::lists([
- 'where' => [
- ['store_id' => $store_ids],
- ['status' => StatusEnum::ENABLED],
- ['coupon_status' => AddonsCouponEnum::STATUS_RECEIVING],
- ],
- 'select' => $select
- ]);
- $coupon_ids = array_column($coupon_list, 'id');
- $relate_list = $this->user_id ? StoreCouponUserRelate::lists(['where' => [['coupon_id' => $coupon_ids], ['from_type' => 2], ['user_id' => $this->user_id]], 'index' => 'coupon_id']) : [];
- $coupon_rows = [];
- foreach ($coupon_list as $item) {
- $item['is_receive'] = 0;
- if (isset($relate_list[$item['id']])) {
- $item['is_receive'] = 1;
- $item['is_use'] = $relate_list[$item['id']]['is_use'];
- }
- $coupon_rows[$item['store_id']][] = $item;
- }
- // $goods_list =StoreGoods::lists([
- // 'where'=>[['store_id'=>$store_ids]],
- // 'select'=>'sum(virtual_sales) as virtual_sales,sum(sales_num) as sales_num,store_id',
- // 'group'=>'store_id',
- // 'index'=>'store_id'
- // ]);
- // $location_obj = new LocationHelper();
- $store_goods_arr = [];
- if(isset($store_goods_list)){
- foreach ($store_goods_list as $val){
- $store_goods_arr[$val['store_id']][]=$val;
- }
- }
- $store_score_deduction = (new StoreSettingService(['mall_id'=>$this->mall_id]))->getDeductionProportion(['store_id'=>$store_ids]);
- $decoration = \Yii::$app->services->setting->addons->get($mall_id, StoreEnum::ADDONS_NAME, 'decoration');
- foreach ($list as &$item) {
- if(!empty($decoration['custom_store_style'])){
- $item['store_style'] = $item['show_style']??1;
- $item['default_store_cate_style'] = $item['default_store_cate_style']??1;
- }else{
- $item['store_style'] = $decoration['default_store_style']??1;
- $item['default_store_cate_style'] = $decoration['default_store_cate_style']??1;
- }
- $item['store_goods_list'] = $store_goods_arr[$item['id']]??[];
- $item['coupon_list'] = $coupon_rows[$item['id']] ?? [];
- $item['order_comment'] = '';
- $item['store_score_deduction'] = $store_score_deduction[$item['id']]??[];
- // $distance = $location_obj->getDistanceByGeo($item['latitude'],$item['longitude'],$latitude,$longitude);
- // $item['distance'] = bcmul($distance,1,1);
- if(empty($item['bannar_pic'])){
- $item['bannar_pic'] = [];
- }else{
- $item['bannar_pic'] = json_decode($item['bannar_pic'],true);
- }
- // if(isset($goods_list[$item['id']])){
- // $item['sales_volume'] += $goods_list[$item['id']]['virtual_sales'];
- // }
- }
- }
- $list_page['list'] = $list;
- $list_page['page'] = $page;
- $list_page['page_size'] = $limit;
- $list_page['count'] = $count;
- $list_page['page_count'] = ceil($count / $limit);
- } else {
- $list_page['list'] = [];
- $list_page['page'] = 0;
- $list_page['page_size'] = 10;
- $list_page['count'] = 0;
- $list_page['page_count'] = 0;
- }
- return $this->success('成功', $list_page);
- }
- /**
- * 更多门店
- *
- * @return mixed
- */
- public function actionStoreMore()
- {
- $params = Yii::$app->request->get();
- $service = new StoreService();
- $params['mall_id'] = $this->mall_id;
- $MoreStore = $service->getMoreStore($params);
- return $this->success('获取成功', compact('MoreStore'));
- }
- public function actionStoreCate()
- {
- $list = StoreCate::lists(['where' => ['mall_id' => $this->mall_id, 'is_show' => 1, 'status' => StatusEnum::ENABLED], 'select' => 'id,parent_id,name']);
- $list = StoreCate::getTreeMenu($list, 0);
- return $this->success('ok', compact('list'));
- }
- public function actionCate()
- {
- $params = \Yii::$app->request->get();
- $cate_id = empty($params['cate_id']) ? 0 : $params['cate_id'];
- $params['where'] = [['mall_id' => $this->mall_id, 'parent_id' => $cate_id, 'is_show' => 1, 'status' => StatusEnum::ENABLED]];
- $params['select'] = 'id,name,pic,advert_pic,advert_url';
- $params['order'] = 'sort desc';
- $cate_list = StoreCate::listPage($params);
- if (false === $cate_list) {
- return $this->error(StoreCate::getStaticError());
- }
- if (!empty($cate_list['list'])) {
- foreach ($cate_list['list'] as &$lv) {
- if (!empty($lv['advert_pic'])) {
- $lv['advert_pic'] = json_decode($lv['advert_pic'], true);
- }
- if (!empty($lv['advert_url'])) {
- $lv['advert_url'] = json_decode($lv['advert_url'], true);
- }
- }
- }
- $cate = StoreCate::find()
- ->select('id,name,pic,advert_pic,advert_url')
- ->where(['mall_id' => $this->mall_id, 'id' => $cate_id, 'is_show' => 1, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->one();
- if (!empty($cate['advert_pic'])) {
- $cate['advert_pic'] = json_decode($cate['advert_pic'], true);
- }
- if (!empty($cate['advert_url'])) {
- $cate['advert_url'] = json_decode($cate['advert_url'], true);
- }
- $cate_list['cate_info'] = $cate;
- return $this->success('操作成功', $cate_list);
- }
- //判断是否是核销员
- public function actionIsClerk()
- {
- $mall_id = $this->mall_id;
- $user_id = $this->user_id;
- $rse = StoreClerk::getOne([['mall_id' => $mall_id], ['user_id' => $user_id], ['status' => StatusEnum::ENABLED]]);
- if (empty($rse)) return $this->error('你不是核销员');
- return $this->success('操作成功', ['store_id' => $rse['store_id']]);
- }
- //核销
- public function actionClerk()
- {
- $params = Yii::$app->request->post();
- $storeService = new StoreService();
- $storeService->mall_id = $this->mall_id;
- $storeService->store_id = $this->store_id;
- $params['clerk_id'] = $storeService->getClerkIdByUserId($this->user_id);
- $mall_id = $this->mall_id;
- $user_id = $this->user_id;
- $params['mall_id'] = $mall_id;
- $rse = StoreClerk::getOne([['mall_id' => $mall_id], ['user_id' => $user_id], ['status' => StatusEnum::ENABLED]]);
- if (empty($rse)) return $this->error('你不是核销员');
- $params['store_id'] = $rse['store_id'];
- $params['user_id'] = $user_id;
- $rse = StoreClerkLog::setData($params);
- if ($rse == false) return $this->error(StoreClerkLog::getStaticError());
- return $this->success('操作成功');
- }
- //核销记录表
- // 暂时不要,备份
- // 使用新写的 actionClerkLog()
- public function actionClerkLogBackup()
- {
- $params = \Yii::$app->request->get();
- $params['mall_id'] = $this->mall_id;
- $params['clerk_id'] = $this->user_id;
- $params['where'] = [
- ['mall_id' => $this->mall_id],
- ['clerk_id' => $this->user_id],
- // ['store_id' => $params['store_id']],
- ['status' => StatusEnum::ENABLED],
- ];
- $params['order'] = 'id desc';
- $list_page = StoreClerkLog::listPage($params);
- if (!empty($list_page['list'])) {
- $order_nos = array_column($list_page['list'], 'order_no');
- $user_ids = array_column($list_page['list'], 'user_id');
- $user_list = User::lists(['where' => [['id' => $user_ids]], 'select' => 'id,nickname,avatar_url', 'index' => 'id']);
- $order_list = Order::lists([
- 'where' => [['order_no' => $order_nos]],
- 'select' => 'id,pay_money,order_no',
- 'with' => ['detail'],
- 'index' => 'order_no'
- ]);
- foreach ($list_page['list'] as &$item) {
- $item['nickname'] = '';
- $item['avatar_url'] = '';
- $item['clerk_status'] = '已核销';
- if (isset($user_list[$item['user_id']])) {
- $item['nickname'] = $user_list[$item['user_id']]['nickname'];
- $item['avatar_url'] = $user_list[$item['user_id']]['avatar_url'];
- }
- $item['details'] = [];
- $item['total_num'] = 0;
- $item['order_id'] = 0;
- if (isset($order_list[$item['order_no']])) {
- $item['order_id'] = $order_list[$item['order_no']]['id'];
- $details = [];
- foreach ($order_list[$item['order_no']]['detail'] as $val) {
- $details[] = [
- 'goods_name' => $val['goods_name'],
- 'num' => $val['num'],
- 'pic_url' => $val['pic_url'],
- 'price' => $val['price'],
- ];
- $item['total_num'] += $val['num'];
- }
- $item['details'] = $details;
- }
- }
- }
- return $this->success('操作成功', $list_page);
- }
- // 已核销和未核销的订单
- public function actionClerkLog()
- {
- $params = \Yii::$app->request->get();
- $params['take_status'] = $params['take_status'] ?? 0;
- $order_params['order'] = 'id desc';
- $order_params['with'] = ['detail', 'base_user'];
- $order_params['select'] = 'id,mall_id,pay_money,store_id,shipping_type,order_no,order_status,user_id';
- $order_params['where'] = [
- ['mall_id' => $this->mall_id],
- ['store_id' => $params['store_id']],
- ['shipping_type' => ShippingTypeEnum::PICKUP]
- ];
- if ($params['take_status'] == 1) { // 已核销
- $order_params['where'][] = ['order_status' => [OrderStatusEnum::TAKE_FINISH, OrderStatusEnum::ACCOMPLISH]];
- } else if ($params['take_status'] == 2) { // 待核销
- $order_params['where'][] = ['order_status' => OrderStatusEnum::TAKE];
- } else { // 全部
- $order_params['where'][] = ['order_status' => [OrderStatusEnum::TAKE, OrderStatusEnum::TAKE_FINISH, OrderStatusEnum::ACCOMPLISH]];
- }
- $order_params['limit'] = $params['limit'] ?? 10;
- $order_list = Order::listPage($order_params, false);
- $order_nos = array_column($order_list['list'], 'order_no');
- $clerk_log = StoreClerkLog::lists([
- 'where' => [['order_no' => $order_nos]],
- 'select' => '*',
- 'index' => 'order_no'
- ]);
- foreach ($order_list['list'] as $key => $item) {
- $item['nickname'] = $item['base_user']['nickname'] ?? '';
- $item['avatar_url'] = $item['base_user']['avatar_url'] ?? '';
- if (in_array($item['order_status'], [OrderStatusEnum::TAKE_FINISH, OrderStatusEnum::ACCOMPLISH])) {
- $item['clerk_status'] = '已核销';
- } else {
- $item['clerk_status'] = '待核销';
- }
- $item['details'] = $item['detail'];
- $item['total_num'] = count($item['detail']);
- $item['order_id'] = $item['id'];
- $item['clerk_id'] = '';
- if (isset($clerk_log[$item['order_no']])) {
- $clerk = $clerk_log[$item['order_no']];
- $item['clerk_id'] = $clerk['clerk_id'] ?? 0;
- $item['mobile'] = $clerk['mobile'] ?? '';
- }
- $item['mobile'] = $item['mobile'] ?? '';
- unset($item['detail'], $item['base_user']);
- $order_list['list'][$key] = $item;
- }
- return $this->success('操作成功', $order_list);
- }
- /**
- * @name:
- * @msg: 添加门店聚合页--为你优选商品列表接口
- * @return {*}
- */
- public function actionOptimizationGoodsList()
- {
- if (!\Yii::$app->request->isGet) {
- return $this->error('请求方式错误');
- }
- $longitude = \Yii::$app->request->get('longitude');
- $latitude = \Yii::$app->request->get('latitude');
- $is_main_mall = \Yii::$app->request->get('is_main_mall',0);
- $goods_id = \Yii::$app->request->get('goods_id');
- if (empty($longitude) || empty($latitude)) {
- return $this->error('您未定位,请定位后预览!');
- }
- $good_ids = [];
- if(!$is_main_mall){
- $wheres = ['mall_id' => $this->mall_id, 'addons_name' => StoreEnum::ADDONS_NAME, 'status' => StatusEnum::ENABLED];
- $res = AddonsMarketingSetting::findOne($wheres);
- if ($res == false) return $this->success('success', []);
- $data = $res->toArray();
- $content = json_decode($data['content'], true);
- // dd($content);
- if (empty($content[4]['data']['goods'])) {
- return $this->success('success', []);
- }
- foreach ($content[4]['data']['goods'] as $good) {
- $good_ids[] = $good['params']['id'] ?? 0;
- }
- $good_ids = array_unique($good_ids);
- }else{
- if(!empty($goods_id)){
- $good_ids = explode(',',$goods_id);
- }
- }
- $goods = StoreGoods::find()
- ->alias('sg')
- ->select('sg.*')
- ->join('INNER JOIN', Store::tableName() . ' as s', 'sg.store_id = s.id')
- ->with(['attr'])
- ->where(['sg.mall_id' => $this->mall_id, 'sg.status' => StatusEnum::ENABLED, 'sg.id' => $good_ids, 'sg.check_status' => StoreEnum::CHECK_ADOPT, 'sg.is_on_sale' => 1, 's.status' => StatusEnum::ENABLED, 's.check_status' => StoreEnum::CHECK_ADOPT])
- ->andWhere(['or', ['>', 'expire_time', time()], ['expire_time' => 0]])
- ->asArray()
- ->all();
- if (!empty($goods)) {
- $store_ids = array_column($goods, 'store_id');
- $stores = Store::find()
- ->select('id,longitude,latitude,store_name,logo_img')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'check_status' => StoreEnum::CHECK_ADOPT,'id'=>$store_ids])
- ->asArray()
- ->indexBy('id')
- ->all();
- $comment_scores = OrderComments::find()
- ->select('goods_id,score')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'store_id' => $store_ids, 'goods_id' => $good_ids])
- ->asArray()
- ->all();
- $select = 'id,name,store_id,type,expire_type,expire_day,effect_days,begin_at,end_at,appoint_type,rule,discount_limit,sub_price,discount,min_price,coupon_status';
- $store_coupon_goods_relates = StoreCouponGoodsRelate::lists([
- 'where' => [['goods_id' => $good_ids]],
- 'index' => 'goods_id'
- ]);
- $coupon_ids = array_column($store_coupon_goods_relates, 'coupon_id');
- $coupon_list = StoreCoupon::lists([
- 'where' => [
- ['id' => $coupon_ids],
- ['status' => StatusEnum::ENABLED],
- ['coupon_status' => StoreEnum::STATUS_RECEIVING],
- ],
- 'select' => $select,
- 'index' => 'id',
- 'group' => 'id'
- ]);
- $coupon_ids = array_column($coupon_list, 'id');
- $user_relate = StoreCouponUserRelate::lists([
- 'where' => [
- ['user_id' => $this->user_id],
- ['from_type' => 1],
- ['coupon_id' => $coupon_ids],
- ],
- 'index' => 'coupon_id',
- ]);
- // dd($comment_scores);
- $good_comment_rate_map = [];
- if (!empty($comment_scores)) {
- foreach ($comment_scores as $val) {
- if (empty($scores[$val['goods_id']])) {
- $scores[$val['goods_id']] = [
- 'all' => 0,
- 'good_comment' => 0,
- ];
- }
- $scores[$val['goods_id']]['all'] += 1;
- if ($val['score'] >= 4) {
- $scores[$val['goods_id']]['good_comment'] += 1;
- }
- }
- foreach ($scores as $goods_id => $score) {
- if ($score['all'] > 0) {
- $good_comment_rate_map[$goods_id] = bcdiv($score['good_comment'], $score['all'], 2);
- } else {
- $good_comment_rate_map[$goods_id] = 0;
- }
- }
- }
- foreach ($goods as $gk => &$good) {
- $store = $stores[$good['store_id']] ?? [];
- $distance = DebrisHelper::getDistance($latitude, $longitude, $store['latitude'] ?? '', $store['longitude'] ?? '');
- if ($distance >= 1000) {
- $distance = round($distance / 1000, 1) . 'km';
- } else {
- $distance .= 'm';
- }
- $good['distance'] = $distance;
- $good['store_name'] = $store['store_name'] ?? '';
- $good['logo_img'] = $store['logo_img'] ?? '';
- $good['good_comment_rate'] = ($good_comment_rate_map[$good['id']] ?? 0) * 100;
- $good['coupon_list'] = [];
- $goods_id = $good['id'];
- if (isset($store_coupon_goods_relates[$goods_id])) {
- $coupon_id = $store_coupon_goods_relates[$goods_id]['coupon_id'];
- if (isset($coupon_list[$coupon_id])) {
- $coupon = [
- 'id' => $coupon_list[$coupon_id]['id'],
- 'name' => $coupon_list[$coupon_id]['name'],
- 'is_receive' => 0,
- ];
- if (isset($user_relate[$coupon['id']])) $coupon['is_receive'] = 1;
- $good['coupon_list'] = $coupon;
- }
- }
- }
- }
- return $this->success('success', $goods);
- }
- public function actionOptimizationStoresList()
- {
- if (!\Yii::$app->request->isGet) {
- return $this->error('请求方式错误');
- }
- $longitude = \Yii::$app->request->get('longitude');
- $latitude = \Yii::$app->request->get('latitude');
- if (empty($longitude) || empty($latitude)) {
- return $this->error('参数错误');
- }
- $wheres = ['mall_id' => $this->mall_id, 'addons_name' => StoreEnum::ADDONS_NAME, 'status' => StatusEnum::ENABLED];
- $res = AddonsMarketingSetting::findOne($wheres);
- if ($res){
- $data = $res->toArray();
- $content = json_decode($data['content'], true);
- if (!empty($content[3]['data']['goods'])) {
- $store_ids = [];
- foreach ($content[3]['data']['goods'] as $good) {
- $store_ids[] = $good['params']['id'] ?? 0;
- }
- $store_ids = array_unique($store_ids);
- }
- }
- $where = ['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'check_status' => StoreEnum::CHECK_ADOPT];
- $stores = Store::find()
- ->select('id,store_name,logo_img,longitude,latitude,praise')
- ->where($where)
- ->andWhere(['or', ['>', 'expire_time', time()], ['expire_time' => 0]])
- ->asArray()
- ->all();
- if (!empty($stores)) {
- $where = ['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'check_status' => StoreEnum::CHECK_ADOPT];
- $good_sales = StoreGoods::find()
- ->select('store_id,sum(sales_num) as sales_num,sum(virtual_sales) as virtual_sales')
- ->where($where)
- ->groupBy('store_id')
- ->asArray()
- ->indexBy('store_id')
- ->all();
- $select = 'id,name,store_id,type,expire_type,expire_day,effect_days,begin_at,end_at,appoint_type,rule,discount_limit,sub_price,discount,min_price,coupon_status';
- $where = [
- ['status' => StatusEnum::ENABLED],
- ['coupon_status' => StoreEnum::STATUS_RECEIVING],
- ];
- $coupon_list = StoreCoupon::lists([
- 'where' => $where,
- 'select' => $select,
- 'index' => 'store_id',
- 'group' => 'store_id'
- ]);
- $coupon_ids = array_column($coupon_list, 'id');
- $user_relate = StoreCouponUserRelate::lists([
- 'where' => [
- ['user_id' => $this->user_id],
- ['from_type' => 1],
- ['coupon_id' => $coupon_ids],
- ],
- 'index' => 'coupon_id',
- ]);
- foreach ($stores as &$store) {
- $sales = $good_sales[$store['id']] ?? [];
- $store['sales_volume'] = $sales['sales_num'] + $sales['virtual_sales'];
- $distance = DebrisHelper::getDistance($latitude, $longitude, $store['latitude'] ?? '', $store['longitude'] ?? '');
- if ($distance >= 1000) {
- $distance = bcdiv($distance, 1000, 1) . 'km';
- } else {
- $distance .= 'm';
- }
- $store['distance'] = $distance;
- $store['coupon_list'] = [];
- $store_id = $store['id'];
- if (isset($coupon_list[$store_id])) {
- $coupon = [
- 'id' => $coupon_list[$store_id]['id'],
- 'name' => $coupon_list[$store_id]['name'],
- 'is_receive' => 0,
- ];
- if (isset($user_relate[$coupon['id']])) $coupon['is_receive'] = 1;
- $store['coupon_list'] = $coupon;
- }
- }
- }
- return $this->success('success', $stores);
- }
- //领取优惠券
- public function actionReceiveCoupon()
- {
- $params = \Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['type', 'receive_type', 'coupon_id'], 'required'],
- [['coupon_share_log_id','from_type'], 'safe'],
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $params['num'] = 1;//数量
- $params['receive_platform'] = $this->platform ?? 'h5';
- $params['user'] = $this->user;
- $user_coupon_id = 0;
- if ($params['type'] == 1) {
- //领取平台优惠券 -- 商品详情页公开领取
- $res = StoreCouponUserRelate::setData($params);
- if ($res == false) return $this->error(StoreCouponUserRelate::getStaticError());
- $user_coupon_id = $res;
- } else {
- if ($params['receive_type'] == 6 && empty($params['coupon_share_log_id'])) {
- // 扫描后台生成的海报进行领取(没有coupon_share_log_id),商城私发的优惠券也是走公开领取的逻辑
- $params['receive_type'] = StoreEnum::SEND_FROM1;
- $res = StoreCouponUserRelate::setData($params);
- if ($res == false) return $this->error(StoreCouponUserRelate::getStaticError());
- $user_coupon_id = 0;
- } elseif ($params['receive_type'] == 6 && !empty($params['coupon_share_log_id'])) {
- // 领取转赠优惠券 -- 好友转赠
- $params['receive_type'] = StoreEnum::SEND_FROM6;
- $res = StoreCouponUserRelate::receiveByGive($params);
- if ($res == false) return $this->error(StoreCouponUserRelate::getStaticError());
- } else {
- return $this->error('参数错误');
- }
- }
- return $this->success('领取成功', ['user_coupon_id' => $user_coupon_id]);
- }
- //转赠优惠券
- public function actionCouponGive()
- {
- if (!\Yii::$app->request->isPost) return $this->error('请求方式错误');
- $user_coupon_id = \Yii::$app->request->post('user_coupon_id');
- $receive_user_id = \Yii::$app->request->post('receive_user_id');
- if (empty($user_coupon_id)) return $this->error('参数错误');
- $wheres = [
- 'mall_id' => $this->mall_id,
- 'id' => $user_coupon_id,
- 'is_force_failure' => 0,
- 'is_use' => 0,
- 'status' => StatusEnum::ENABLED,
- 'coupon_status' => AddonsCouponEnum::STATUS_RECEIVING
- ];
- $user_coupon = StoreCouponUserRelate::find()
- ->where($wheres)->andWhere(['or', ['is_giving' => 0], ['is_giving' => 1, 'giving_status' => [0, 1]]])->one();
- if (empty($user_coupon)) return $this->error('当前优惠券不可转赠');
- $from_type = $user_coupon['from_type'];
- $coupon_id = $user_coupon['coupon_id'];
- $coupon_class = $from_type == 1 ? AddonsCoupon::class : StoreCoupon::class;
- $coupon = $coupon_class::findOne(['mall_id' => $this->mall_id, 'id' => $coupon_id, 'coupon_status' => 2, 'status' => StatusEnum::ENABLED]);
- if (empty($coupon)) return $this->error('优惠券不存在或者已经失效');
- if ($coupon['is_giving'] != 1) return $this->error('优惠券不可转赠');
- $params = [
- 'mall_id' => $this->mall_id,
- 'coupon_id' => $coupon_id,
- 'store_id' => $user_coupon['store_id'],
- 'user_coupon_id' => $user_coupon_id,
- 'giving_user_id' => $this->user_id,
- ];
- $res = StoreCouponShareLog::setData($params);
- if (!$res) {
- return $this->error(StoreCouponShareLog::getStaticError());
- }
- // 如果有接收用户ID,则执行直接转赠
- if (!empty($receive_user_id)) {
- $params = [
- 'mall_id' => $this->mall_id,
- 'coupon_share_log_id' => $res->id, // 注意这里改为 ->id 而不是 ['id']
- 'coupon_id' => $coupon_id,
- 'user_id' => $receive_user_id,
- 'num' => 1,
- 'receive_platform' => $this->platform ?? '',
- 'direct_gift' => 1,
- ];
- if (!StoreCouponUserRelate::receiveByGive($params)) {
- return $this->error(StoreCouponShareLog::getStaticError());
- }
- }
- return $this->success('转赠成功', ['coupon_share_log_id' => $res->id]);
- }
- public function actionMyCouponList()
- {
- $params = \Yii::$app->request->get();
- $from_type = !empty($params['from_type']) ? $params['from_type'] : 1;
- $where[] = ['mall_id' => $this->mall_id];
- if ($from_type == 3) {
- $where[] = ['user_id' => $this->user_id];
- //历史记录
- $status = !empty($params['status']) ? $params['status'] : 0;
- //状态
- switch ($status) {
- case 0:
- //正常
- $where[] = ['is_use' => 0];
- $where[] = ['is_giving' => 0];
- $where[] = ['coupon_status' => 2];
- break;
- case 1:
- //已使用
- $where[] = ['is_use' => 1];
- break;
- case 2:
- //已失效
- $where[] = ['coupon_status' => [3, 4]];
- break;
- case 3:
- //已赠送
- $where[] = ['is_giving' => 1];
- break;
- }
- $params['order'] = 'id desc';
- $params['where'] = $where;
- $params['select'] = 'id as user_coupon_id,coupon_id,store_id,start_time,end_time,from_type,updated_at,is_use,is_giving';
- $page_list = StoreCouponUserRelate::listPage($params);
- if (!empty($page_list['list'])) {
- $coupon_ids = array_column($page_list['list'], 'coupon_id');
- switch ($from_type) {
- case 3:
- $store_coupon_ids = $platform_coupon_ids = [];
- foreach ($page_list['list'] as $item) {
- switch ($item['from_type']) {
- case 1:
- $platform_coupon_ids[] = $item['coupon_id'];
- break;
- case 2:
- $store_coupon_ids[] = $item['coupon_id'];
- break;
- }
- }
- if (!empty($store_coupon_ids)) {
- $goods_arr = $this->getGoodsArr(StoreCouponGoodsRelate::class, StoreGoods::class, $store_coupon_ids);
- $goods_cate_arr = $this->getGoodsCateArr(StoreCouponCatRelate::class, StoreGoodsCate::class, $store_coupon_ids);
- $store_coupon_list = StoreCoupon::lists(['where' => [['id' => $coupon_ids]], 'index' => 'id']);
- }
- if (!empty($platform_coupon_ids)) {
- $store_ids = array_column($page_list['list'], 'store_id');
- $store_arr = Store::lists(['where' => [['id' => $store_ids]], 'index' => 'id', 'select' => 'id,store_name']);
- $platform_coupon_list = AddonsCoupon::lists(['where' => [['id' => $coupon_ids]], 'index' => 'id']);
- }
- break;
- }
- if ($status == 3) {
- $user_coupon_ids = array_column($page_list['list'], 'user_coupon_id');
- $share_logs = StoreCouponShareLog::lists(['where' => [['user_coupon_id' => $user_coupon_ids]], 'index' => 'user_coupon_id', 'select' => 'user_coupon_id,receive_user_id']);
- $receive_user_ids = array_column($share_logs, 'receive_user_id');
- $receive_user_list = User::lists(['where' => [['id' => $receive_user_ids]], 'index' => 'id', 'select' => 'id,mobile,nickname']);
- }
- foreach ($page_list['list'] as &$item) {
- $item['coupon_name'] = $item['rule'] = '';
- $item['appoint_type'] = $item['type'] = $item['min_price'] = $item['discount'] = $item['sub_price'] = 0;
- $item['goods_arr'] = $item['goods_cate_arr'] = $item['store_arr'] = [];
- $item['give_name'] = $item['give_mobile'] = '';
- $item['use_time'] = $item['use_time'] = 0;
- if ($item['is_use']) {
- $item['use_time'] = $item['updated_at'];
- }
- //赠送
- if ($status == 3) {
- if ($item['is_giving']) {
- $item['give_time'] = $item['updated_at'];
- }
- if (isset($share_logs[$item['user_coupon_id']])) {
- $receive_user_id = $share_logs[$item['user_coupon_id']]['receive_user_id'];
- if (isset($receive_user_list) && isset($receive_user_list[$receive_user_id])) {
- $item['give_name'] = $receive_user_list[$receive_user_id]['nickname'];
- $item['give_mobile'] = $receive_user_list[$receive_user_id]['mobile'];
- }
- }
- }
- switch ($from_type) {
- case 3:
- switch ($item['from_type']) {
- case 1:
- if (isset($platform_coupon_list[$item['coupon_id']])) $coupon = $platform_coupon_list[$item['coupon_id']];
- break;
- case 2:
- if (isset($store_coupon_list[$item['coupon_id']])) $coupon = $store_coupon_list[$item['coupon_id']];
- break;
- }
- break;
- }
- if (!empty($coupon)) {
- $item['coupon_name'] = $coupon['name'];
- $item['rule'] = $coupon['rule'];
- $item['appoint_type'] = $coupon['appoint_type'];
- $item['type'] = $coupon['type'];
- $item['min_price'] = $coupon['min_price'];
- $item['discount'] = $coupon['discount'];
- $item['sub_price'] = $coupon['sub_price'];
- }
- if (isset($goods_arr[$item['coupon_id']])) $item['goods_arr'] = $goods_arr[$item['coupon_id']];
- if (isset($goods_cate_arr[$item['coupon_id']])) $item['goods_cate_arr'] = $goods_cate_arr[$item['coupon_id']];
- if (isset($store_arr[$item['store_id']])) $item['store_arr'] = $store_arr[$item['store_id']];
- }
- }
- } else {
- if ($from_type == 1) {
- $coupon_class = AddonsCoupon::class;
- } else {
- $coupon_class = StoreCoupon::class;
- }
- $where[] = ['coupon_status' => 2];
- $where[] = ['is_public_receive' => StatusEnum::ENABLED];
- $where[] = ['<>', 'store_id', ''];
- $where[] = ['status'=>StatusEnum::ENABLED];
- $params['order'] = 'id desc';
- $params['where'] = $where;
- $page_list = $coupon_class::listPage($params);
- if (!empty($page_list['list'])) {
- $coupon_ids = array_column($page_list['list'], 'id');
- $store_ids = array_column($page_list['list'], 'store_id');
- $store_arr = Store::lists(['where' => [['id' => $store_ids]], 'index' => 'id', 'select' => 'id,store_name']);
- if ($from_type == 1) {
- $store_ids = array_column($page_list['list'], 'store_id');
- $store_arr = Store::lists(['where' => [['id' => $store_ids]], 'index' => 'id', 'select' => 'id,store_name']);
- } else {
- $goods_arr = $this->getGoodsArr(StoreCouponGoodsRelate::class, StoreGoods::class, $coupon_ids);
- $goods_cate_arr = $this->getGoodsCateArr(StoreCouponCatRelate::class, StoreGoodsCate::class, $coupon_ids);
- }
- $user_relate_list = StoreCouponUserRelate::lists([
- 'where' => [
- ['coupon_id' => $coupon_ids],
- ['user_id' => $this->user_id],
- ['status'=>StatusEnum::ENABLED],
- ['is_giving'=>StatusEnum::DISABLED],
- ['giving_status'=>[StatusEnum::ENABLED,StatusEnum::DISABLED]],
- ],
- 'select' => 'id,coupon_id,from_type,is_use,is_giving,coupon_status,start_time,end_time',
- ]);
- $user_relate_arr = [];
- foreach ($user_relate_list as $val) {
- $user_relate_arr[$val['from_type']][$val['coupon_id']] = $val;
- }
- foreach ($page_list['list'] as &$item) {
- $item['coupon_name'] = $item['name'];
- $item['is_gived'] = 0;
- $item['is_use'] = 0;
- $item['is_receive'] = 0;
- $item['user_coupon_id'] = 0;
- $item['goods_arr'] = $item['goods_cate_arr'] = $item['store_arr'] = [];
- if (isset($user_relate_arr[$from_type][$item['id']])) {
- $user_coupon = $user_relate_arr[$from_type][$item['id']];
- $item['is_use'] = $user_coupon['is_use'];
- $item['is_gived'] = $user_coupon['is_giving'];
- $item['user_coupon_id'] = $user_coupon['id'];
- $item['begin_at'] = $user_coupon['start_time'];
- $item['end_at'] = $user_coupon['end_time'];
- $item['is_receive'] = 1;
- if($item['receive_count']>1&&!empty($user_coupon['is_use'])){
- $item['is_receive'] = 0;
- }
- }
- if (isset($goods_arr[$item['id']])) $item['goods_arr'] = $goods_arr[$item['id']];
- if (isset($goods_cate_arr[$item['id']])) $item['goods_cate_arr'] = $goods_cate_arr[$item['id']];
- if (isset($store_arr[$item['store_id']])) $item['store_arr'] = $store_arr[$item['store_id']];
- }
- }
- }
- return $this->success('success', $page_list);
- }
- protected function getGoodsArr($relate_class, $goods_class, $coupon_ids)
- {
- $store_coupon_goods_relate_list = $relate_class::lists(['where' => [['coupon_id' => $coupon_ids]]]);
- $goods_ids = array_column($store_coupon_goods_relate_list, 'goods_id');
- $goods_list = $goods_class::lists(['where' => [['id' => $goods_ids]], 'select' => 'id,goods_name', 'index' => 'id']);
- $goods_arr = [];
- foreach ($store_coupon_goods_relate_list as $item) {
- if (isset($goods_list[$item['goods_id']])) {
- $goods_arr[$item['coupon_id']][] = $goods_list[$item['goods_id']];
- }
- }
- return $goods_arr;
- }
- protected function getGoodsCateArr($relate_class, $cate_class, $coupon_ids)
- {
- $goods_cate_arr = [];
- $store_coupon_cate_relate_list = $relate_class::lists(['where' => [['coupon_id' => $coupon_ids]]]);
- $cate_ids = array_column($store_coupon_cate_relate_list, 'cate_id');
- $goods_cate_list = $cate_class::lists(['where' => [['id' => $cate_ids]], 'select' => 'id,name', 'index' => 'id']);
- foreach ($store_coupon_cate_relate_list as $item) {
- if (isset($goods_cate_list[$item['cate_id']])) {
- $goods_cate_arr[$item['coupon_id']][] = $goods_cate_list[$item['cate_id']];
- }
- }
- return $goods_cate_arr;
- }
- //优惠券列表
- public function actionCouponList()
- {
- $params = \Yii::$app->request->get();
- $from_type = !empty($params['from_type']) ? $params['from_type'] : 1;
- $where[] = ['mall_id' => $this->mall_id];
- $where[] = ['status' => StatusEnum::ENABLED];
- $where[] = ['coupon_status' => 2];
- $params['select'] = 'id,name,store_id,type,expire_type,expire_day,effect_days,begin_at,end_at,appoint_type,rule,discount_limit,sub_price,discount,min_price,coupon_status';
- switch ($from_type) {
- case 1:
- $where[] = ['<>', 'store_id', ''];
- $class = AddonsCoupon::class;
- break;
- case 2:
- $params['select'] = 'id,name as coupon_name,discount,discount_limit,min_price,sub_price,type,mall_id,store_id,expire_type,
- expire_day,begin_at,end_at,first_frame,video_url,watch_times';
- $class = StoreCoupon::class;
- break;
- }
- $params['where'] = $where;
- $params['order'] = 'id desc';
- $page_list = $class::listPage($params);
- if (!empty($page_list)) {
- $coupon_ids = array_column($page_list['list'], 'id');
- switch ($from_type) {
- case 1:
- case 2:
- switch ($from_type) {
- case 1:
- $store_ids = array_column($page_list['list'], 'store_id');
- $store_arr = Store::lists(['where' => [['id' => $store_ids]], 'index' => 'id', 'select' => 'id,store_name']);
- break;
- case 2:
- $goods_arr = $this->getGoodsArr(StoreCouponGoodsRelate::class, StoreGoods::class, $coupon_ids);
- $goods_cate_arr = $this->getGoodsCateArr(StoreCouponCatRelate::class, StoreGoodsCate::class, $coupon_ids);
- }
- break;
- }
- foreach ($page_list['list'] as &$item) {
- $item['goods_arr'] = $item['goods_cate_arr'] = $item['store_arr'] = [];
- $item['from_type'] = $from_type;
- $item['from_type_text'] = $from_type == 1 ? '平台优惠券' : '门店优惠券';
- if (isset($goods_arr[$item['id']])) $item['goods_arr'] = $goods_arr[$item['id']];
- if (isset($goods_cate_arr[$item['id']])) $item['goods_cate_arr'] = $goods_cate_arr[$item['id']];
- if (isset($store_arr[$item['store_id']])) $item['store_arr'] = $store_arr[$item['store_id']];
- }
- }
- $page_list['expire_type_map'] = StoreEnum::getExpireTypeMap();
- $page_list['appoint_type_map'] = StoreEnum::getAppointTypeMap();
- $page_list['coupon_status_map'] = StoreEnum::getCouponStatusMap();
- return $this->success('success', $page_list);
- }
- public function actionCouponListByStoreId()
- {
- $params = \Yii::$app->request->get();
- if (empty($params['store_id'])) return $this->success('success', []);
- $store_id = $params['store_id'];
- $where[] = ['mall_id' => $this->mall_id];
- $where[] = ['status' => StatusEnum::ENABLED];
- $where[] = ['coupon_status' => 2];
- $where[] = ['store_id' => [$store_id]];
- $params['where'] = $where;
- $params['order'] = 'id desc';
- $params['select'] = 'id,name,store_id,type,expire_type,expire_day,effect_days,begin_at,end_at,appoint_type,rule,discount_limit,sub_price,discount,min_price,coupon_status';
- $platform_coupon_list = AddonsCoupon::lists($params);
- $coupon_ids = array_column($platform_coupon_list, 'id');
- $relate_list = StoreCouponUserRelate::lists(['where' => [['coupon_id' => $coupon_ids], ['user_id' => $this->user_id], ['from_type' => 1]], 'index' => 'coupon_id']);
- foreach ($platform_coupon_list as &$item) {
- $item['is_receive'] = 0;
- if (isset($relate_list[$item['id']])) {
- $item['is_receive'] = 1;
- $item['is_use'] = $relate_list[$item['id']]['is_use'];
- }
- }
- $params['select'] = 'id,name,discount,discount_limit,min_price,sub_price,type,mall_id,store_id,expire_type,
- expire_day,begin_at,end_at,first_frame,video_url,watch_times';
- $store_coupon_list = StoreCoupon::lists($params);
- $coupon_ids = array_column($store_coupon_list, 'id');
- $relate_list = StoreCouponUserRelate::lists(['where' => [['coupon_id' => $coupon_ids], ['user_id' => $this->user_id], ['from_type' => 2]], 'index' => 'coupon_id']);
- foreach ($store_coupon_list as &$item) {
- $item['is_receive'] = 0;
- if (isset($relate_list[$item['id']])) {
- $item['is_receive'] = 1;
- $item['is_use'] = $relate_list[$item['id']]['is_use'];
- }
- }
- $list = [
- 'store_coupon_list' => $store_coupon_list,
- 'platform_coupon_list' => $platform_coupon_list,
- ];
- $list['expire_type_map'] = StoreEnum::getExpireTypeMap();
- $list['appoint_type_map'] = StoreEnum::getAppointTypeMap();
- $list['coupon_status_map'] = StoreEnum::getCouponStatusMap();
- return $this->success('success', $list);
- }
- /**
- * @name:
- * @msg: 优惠券信息
- * @param {integer} $coupon_id 优惠券 id
- * @return {*}
- */
- public function actionCouponInfo()
- {
- if (!\Yii::$app->request->isGet) return $this->error('请求方式错误');
- $user_id = $this->user_id;
- $coupon_share_log_id = \Yii::$app->request->get('coupon_share_log_id');
- $coupon_id = \Yii::$app->request->get('coupon_id');
- $coupon = [];
- if(!empty($coupon_share_log_id)){
- // 转赠优惠券
- $coupon_share = StoreCouponShareLog::findOne(['id' => $coupon_share_log_id, 'mall_id' => $this->mall_id]);
- if (empty($coupon_share)) return $this->error('未找到相应的分享记录');
- $coupon_user = StoreCouponUserRelate::findOne(['id' => $coupon_share['user_coupon_id']]);
- if (empty($coupon_user)) return $this->error('未找到相应的分享记录');
- if ($coupon_user['from_type'] == 1) {
- $coupon = AddonsCoupon::find()->where(['id' => $coupon_share['coupon_id'], 'mall_id' => $this->mall_id])->asArray()->one();
- } else {
- $coupon = StoreCoupon::find()->where(['id' => $coupon_share['coupon_id'], 'mall_id' => $this->mall_id])->asArray()->one();
- }
- if(empty($coupon)) return $this->error('优惠券不存在');
- $store = Store::findOne(['id' => $coupon['store_id']]);
- $mall_log = $store['logo_img'];
- $mall_name = $store['store_name'];
- $coupon_id = $coupon['id'];
- $user_id = $coupon_share->giving_user_id;
- $user_coupon_info = StoreCouponUserRelate::find()
- ->select('start_time,end_time,coupon_status')
- ->where(['id' => $coupon_share['user_coupon_id'], 'mall_id' => $this->mall_id, 'user_id' => $user_id, 'is_giving' => 1])
- ->orderBy('id desc')
- ->limit(1)
- ->asArray()
- ->one();
- }else{
- if(!empty($coupon_id)){
- // 非转赠优惠券
- $coupon = StoreCoupon::find()->where(['id' => $coupon_id, 'mall_id' => $this->mall_id])->asArray()->one();
- if(empty($coupon)) return $this->error('优惠券不存在');
- $store = Store::findOne(['id' => $coupon['store_id']]);
- $mall_log = $store['logo_img'];
- $mall_name = $store['store_name'];
- $coupon_id = $coupon['id'];
- $user_id = 0;
- }
- $user_coupon_info = StoreCouponUserRelate::find()
- ->select('start_time,end_time,coupon_status')
- ->where(['coupon_id' => $coupon_id, 'mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'is_giving' => 0])
- ->orderBy('id desc')
- ->limit(1)
- ->asArray()
- ->one();
- }
- if (!empty($user_coupon_info)) {
- $coupon = array_merge($coupon, $user_coupon_info);
- $coupon = array_merge($coupon, AddonsCoupon::parseCouponInfo($coupon, true));
- } else {
- $coupon = array_merge($coupon, AddonsCoupon::parseCouponInfo($coupon));
- }
- $user = User::findOne(['id' => $user_id, 'mall_id' => $this->mall_id]);
- if (empty($user)) {
- $coupon_picture = $mall_log;
- $coupon_user_name = $mall_name;
- } else {
- $coupon_picture = $user->avatar_url ?: \Yii::$app->request->hostInfo . '/resources/img/mall/default_avatar_url.png';
- $coupon_user_name = ($user->nickname ?: $user->username) ?: '会员';
- }
- $coupon['coupon_picture'] = $coupon_picture;
- $coupon['give_user_name'] = $coupon_user_name;
- $coupon['is_lapse'] = in_array($user_coupon_info['coupon_status'], [AddonsCouponEnum::STATUS_EXPIRED, AddonsCouponEnum::STATUS_FAILURE]) ||
- $user_coupon_info['is_use'] == 1 ||
- $user_coupon_info['giving_status'] == AddonsCouponEnum::GIVING_STATUS2;
- $coupon['is_lapse_by_latest_user_coupon'] = false;
- if ($coupon['get_user_coupon_id'] && $coupon_share['receive_user_id'] == $this->user_id) {
- $latest_user_coupon_info = AddonsCouponUserRelate::find()
- ->select('start_time,end_time,coupon_status,is_use,is_giving,giving_status,user_id')
- ->where(['id' => $coupon['get_user_coupon_id'], 'mall_id' => $this->mall_id])
- ->limit(1)
- ->asArray()
- ->one();
- $coupon['is_lapse_by_latest_user_coupon'] = in_array($latest_user_coupon_info['coupon_status'], [AddonsCouponEnum::STATUS_EXPIRED, AddonsCouponEnum::STATUS_FAILURE]) ||
- $latest_user_coupon_info['is_use'] == 1 ||
- $latest_user_coupon_info['giving_status'] == AddonsCouponEnum::GIVING_STATUS2;
- }
-
- $coupon['receive_user_id'] = $coupon_share['receive_user_id'];
- $couponLink = [];
- switch($coupon['appoint_type']){
- case AddonsCouponEnum::APPOINT_TYPE4: // 指定门店
- $couponLink = explode(',',$coupon['store_id']);
- break;
- case AddonsCouponEnum::APPOINT_TYPE6: // 指定门店商品
- $goodsIds = CouponStoreGoodsRelate::find()->select('goods_id')->where(['coupon_id' => $coupon['id']])->asArray()->all();
- $goods_id = [];
- foreach($goodsIds as $k => $v){
- array_push($goods_id, $v['goods_id']);
- }
- $storeGoods = StoreGoods::find()->select('store_id,id')->where(['id' => $goods_id])->asArray()->all();
- $couponLink['store_id'] = [$storeGoods[0]['store_id']];
- $couponLink['goods_id'] = [$storeGoods[0]['id']];
- break;
- }
- $coupon['couponLink'] = $couponLink;
- return $this->success('操作成功', ['coupon_info' => $coupon]);
- }
- //开屏优惠券列表
- public function actionOpenScreenCouponList()
- {
- $where[] = ['mall_id' => $this->mall_id];
- $where[] = ['coupon_status' => 2];
- $where[] = ['is_open_screen' => 1];
- $where[] = ['status' => StatusEnum::ENABLED];
- $where[] = ['<>', 'store_id', ''];
- $params['order'] = 'id desc';
- $params['where'] = $where;
- $params['select'] = 'id,name as coupon_name,discount,discount_limit,min_price,sub_price,type,mall_id,store_id,expire_type,expire_day,begin_at,end_at,effect_days';
- $platform_coupon_list = AddonsCoupon::lists($params);
- $params['select'] = 'id,name as coupon_name,discount,discount_limit,min_price,sub_price,type,mall_id,store_id,expire_type,
- expire_day,begin_at,end_at,first_frame,video_url,watch_times,effect_days,exchange_voucher_type';
- $store_coupon_list = StoreCoupon::lists($params);
- $platform_coupon_list = $this->formatCouponList($platform_coupon_list, 1);
- $store_coupon_list = $this->formatCouponList($store_coupon_list, 2);
- $list = array_merge($platform_coupon_list, $store_coupon_list);
- return $this->success('success', $list);
- }
- protected function formatCouponList($coupon_list, $from_type)
- {
- $coupon_ids = array_column($coupon_list, 'id');
- $relate_list = StoreCouponUserRelate::lists([
- 'where' => [
- ['from_type' => $from_type],
- ['coupon_id' => $coupon_ids],
- ['user_id' => $this->user_id],
- ],
- 'and_where' => ['>', 'end_time', time()],
- 'index' => 'coupon_id'
- ]);
- foreach ($coupon_list as &$item) {
- $item['coupon_id'] = $item['id'];
- $item['from_type'] = $from_type;
- $item['from_type_text'] = $from_type == 1 ? '平台券' : '门店券';
- $item['is_receive'] = $item['is_use'] = $item['user_coupon_id'] = 0;
- if (isset($relate_list[$item['id']])) {
- $item['is_receive'] = 1;
- $item['is_use'] = $relate_list[$item['id']]['is_use'];
- $item['user_coupon_id'] = $relate_list[$item['id']]['id'];
- if(!empty($relate_list[$item['id']]['start_time'])) $item['begin_at'] = $relate_list[$item['id']]['start_time'];
- if(!empty($relate_list[$item['id']]['end_time'])) $item['end_at'] = $relate_list[$item['id']]['end_time'];
- }
- $expire_desc = '';
- switch ($item['expire_type']){
- case 1:
- $expire_desc = '领取后'.$item['expire_day'].'天过期';
- break;
- case 3:
- $expire_desc = '领取后'.$item['effect_days'].'天生效,生效后'.$item['expire_day'].'天过期';
- break;
- }
- $item['expire_desc'] =$expire_desc;
- }
- return $coupon_list;
- }
- public function actionGetContentByCode(){
- $params = \Yii::$app->request->post();
- // 检查提交的参数
- $res = \Yii::$app->services->validate->validate($params,[
- [['code'], 'required'],
- ]);
- if($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $model = StoreMiniCode::findOne(['code'=>$params['code']]);
- if(empty($model)) return $this->error('查无数据');
- $content = json_decode($model['content'],true);
- return $this->success('操作成功',$content);
- }
- public function actionGoodsList(){
- $params = \Yii::$app->request->get();
- $res = \Yii::$app->services->validate->validate($params, [
- [['store_id'], 'required'],
- [['keyword'], 'safe'],
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $store_id = $params['store_id'];
- $where[] = ['store_id'=>$store_id,'mall_id' => $this->mall_id,'check_status'=>1, 'is_on_sale' => 1, 'status' => StatusEnum::ENABLED];
- if(!empty($params['keyword'])){
- $where[]=['like','goods_name',trim($params['keyword'])];
- }
- $params['where'] = $where;
- $params['select'] = 'id,store_id,goods_name,cover_pic,price,original_price,show_style,goods_type';
- $params['order'] = 'is_recommend desc,sort asc';
- $goods_list = StoreGoods::listPage($params);
- if(!empty($goods_list['list'])){
- foreach ($goods_list['list'] as &$item){
- $item['discount'] = $item['original_price'] - $item['price'];
- if($item['discount']<0) $item['discount'] = 0;
- }
- }
- return $this->success('操作成功', $goods_list);
- }
- public function actionCollectAdd()
- {
- $params = \Yii::$app->request->post();
- $res = \Yii::$app->services->validate->validate($params, [
- [['store_id', 'type'], 'required'],
- [['type'], 'in', 'range' => [0, 1]],
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $params['status'] = $params['type'];
- $res = StoreCollect::setData($params);
- if ($res === false) return $this->error(StoreCollect::getStaticError());
- if($params['type'] == StatusEnum::ENABLED){
- $msg = "收藏成功";
- }else{
- $msg = "取消收藏";
- }
- return $this->success($msg, []);
- }
- public function actionGetStoreList(){
- $params = \Yii::$app->request->post();
- $res = \Yii::$app->services->validate->validate($params, [
- [['store_id'], 'required'],
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- }
- /**
- * 支付成功页面-订单信息
- * @return mixed|null
- * @throws \yii\db\Exception
- */
- public function actionPaySuccessOrderInfo()
- {
- $params = Yii::$app->request->get();
- $service = new StoreOrderService(['mall_id' => $this->mall_id]);
- $params['user_id'] = $this->user_id;
- $data = $service->paySuccessOrderInfo($params);
- return $this->success('成功', $data);
- }
- /**
- * 支付成功页面-门店分类
- * @return mixed|null
- * @throws \yii\db\Exception
- */
- public function actionPaySuccessStoreCateList()
- {
- $list = StoreCate::lists([
- 'where'=>[
- ['mall_id'=>$this->mall_id],
- ['parent_id'=>0],
- ['status'=>StatusEnum::ENABLED],
- ],
- 'select'=>'id,name,pic'
- ]);
- return $this->success('成功', ['list'=>$list]);
- }
- public function actionGetAssociatedStore()
- {
- $params = Yii::$app->request->get();
- $StoreAssociatedUserService = new StoreAssociatedUserService();
- $params['user_id'] = $this->user_id;
- $params['mall_id'] = $this->mall_id;
- $store_id = $StoreAssociatedUserService->getStoreAssociated($params);
- return $this->success('成功', [
- 'store_id' => $store_id ? (int)$store_id : null
- ]);
- }
- // 新门店聚合页
- public function actionNewStoreList()
- {
- $settings = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'enter');
- if ($settings['mode'] != 3) {
- $limit = 10;
- } else {
- $limit = $settings['buy_store_num'] ?? 10;
- }
- if ($this->user->parent_id == 0) {
- // 平台任意n家门店
- // $list = StoreEntryLimit::getStoreList($this->mall_id, $limit);
- $list = [];
- } else {
- $list = StoreEntryLimit::getSpecailStoreList($this->user_id, $this->mall_id, $limit);
- }
- return $this->success('成功', $list);
- }
- }
|