| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587 |
- <?php
- namespace addons\Community\common\models;
- use addons\Community\common\enums\CommunityEnum;
- use addons\Community\common\helper\CommunityHelper;
- use addons\Community\common\service\CommunityService;
- use addons\Community\common\service\SettingService;
- use common\enums\GoodsTypeEnum;
- use common\enums\PreviewTypeEnum;
- use common\enums\ShippingTypeEnum;
- use common\enums\StatusEnum;
- use common\helpers\LocationHelper;
- use common\models\base\BaseActiveRecord;
- use common\models\common\Region;
- use common\models\goods\Goods;
- use common\models\goods\GoodsAttr;
- use common\models\goods\GoodsCateRelate;
- use Exception;
- use Yii;
- use yii\helpers\Json;
- use common\models\mall\MallAddons;
- use common\enums\AddonsEnum;
- /**
- * This is the model class for table "qimall_addons_community_head".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $goods_id Goods ID
- * @property int $community_id Community ID
- * @property int $status 状态[0禁用 1启用 -1删除]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- */
- class CommunityGoods extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_community_goods}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'goods_id', 'community_id', 'status', 'created_at', 'updated_at',], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城id',
- 'goods_id' => '商品id',
- 'community_id' => '自提点id',
- 'status' => '状态[0禁用 1启用 -1删除]',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- ];
- }
- public static function saveGoods($params)
- {
- // 后台页面组件展示
- if ($params['type'] == 'show_component') {
- return [
- 'component' => 'com-community-goods',
- 'path' => Yii::$app->basePath . '/../addons/Community/backend/views/components',
- ];
- } else {
- try {
- if (empty($params['setting'][CommunityEnum::ADDONS_NAME])) return true;
- $post = $params['setting'][CommunityEnum::ADDONS_NAME];
- $post['mall_id'] = $params['mall_id'];
- $mall_id = $params['mall_id'];
- $goods_id = $params['goods_id'];
- $enable = $post['enable'];
- $enable_refund = $post['enable_refund'];
- $supported_logistics = json_encode($post['supported_logistics']);
- $setting = CommunityGoodsSetting::setData(compact('mall_id', 'goods_id', 'enable', 'supported_logistics', 'enable_refund'));
- if ($setting === false) throw new Exception(CommunityGoodsSetting::getStaticError());
- if ($enable == StatusEnum::DISABLED) return true;
- $community_ids = $post['community_arr_ids'] ?? [];
- if (count($community_ids) <= 0) return true;
- $params = [
- 'where' => [['mall_id' => $mall_id], ['goods_id' => $goods_id], ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]],
- 'select' => 'community_id'
- ];
- $community_arr = self::lists($params, true);
- $community_arr_ids = array_column($community_arr, 'community_id');
- $community_arr_ids = $community_arr_ids ?? [];
- $community_list_ids = array_unique(array_merge($community_arr_ids, $community_ids));
- // 需要删除的自提点id
- $del_community_ids = array_diff($community_list_ids, $community_ids);
- // 需要插入的自提点id
- $inc_community_ids = array_diff($community_ids, $community_arr_ids);
- if ($del_community_ids) self::batchDelCommunityGoods($del_community_ids, $mall_id, $goods_id);
- if ($inc_community_ids) {
- $data = [];
- foreach ($inc_community_ids as $community_id) {
- $data[] = [$mall_id, $goods_id, $community_id, time(), time()];
- }
- self::batchSetCommunityGoods($data);
- }
- return true;
- } catch (\Exception $e) {
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
- public static function recursionRegions($regions, $deep = 1)
- {
- $ids = [];
- foreach ($regions as $region) {
- if ($deep == 4 && $region['checked']) {
- $ids[] = $region['id'];
- continue;
- }
- if (isset($region['children']) && $region['children']) {
- $new_ids = self::recursionRegions($region['children'], $deep + 1);
- $ids = array_merge($ids, $new_ids);
- }
- }
- return $ids;
- }
- public static function batchSetCommunityGoods($data)
- {
- $connection = Yii::$app->db;
- //数据批量入库
- $count = $connection->createCommand()->batchInsert(
- self::tableName(),
- ['mall_id', 'goods_id', 'community_id', 'created_at', 'updated_at'], //字段
- $data
- )->execute();
- return $count;
- }
- public static function batchDelCommunityGoods($community_ids, $mall_id, $goods_id)
- {
- $community_list = self::findAll(['goods_id' => $goods_id, 'status' => StatusEnum::ENABLED, 'mall_id' => $mall_id, 'community_id' => $community_ids]);
- foreach ($community_list as $community) {
- $community->status = StatusEnum::DELETE;
- $community->save();
- }
- return true;
- }
- public static function setGoodsSetting($mall_id, $community_id)
- {
- $enable_goods = CommunityGoodsSetting::lists([
- 'where' => [['mall_id' => $mall_id], ['status' => StatusEnum::ENABLED], ['enable' => StatusEnum::ENABLED]],
- 'select' => 'goods_id',
- ]);
- $enable_goods = array_column($enable_goods, 'goods_id');
- $enable_goods = $enable_goods ?? [];
- if (empty($enable_goods)) return true;
- $exsit = self::lists([
- 'where' => [['mall_id' => $mall_id], ['status' => StatusEnum::ENABLED], ['community_id' => $community_id]],
- 'select' => 'goods_id'
- ]);
- $exsit_goods_ids = array_column($exsit, 'goods_id');
- $exsit_goods_ids = $exsit_goods_ids ?? [];
- $insert_goods_ids = $enable_goods;
- if ($exsit_goods_ids) $insert_goods_ids = array_diff($enable_goods, $exsit_goods_ids);
- $data = [];
- foreach ($insert_goods_ids as $goods_id) {
- $data[] = [$mall_id, $goods_id, $community_id, time(), time()];
- }
- if ($data) self::batchSetCommunityGoods($data);
- return true;
- }
- public function filterGoodsId($params)
- {
- $mall_id = $params['mall_id'];
- if (!isset($params['location_style']) || $params['location_style'] <= 2) return $params['goods_id'];
- if (!isset($params['user_id']) || $params['user_id'] <= 0) return $params['goods_id'];
- $latest = self::getLatestCommunityOne($mall_id, $params['user_id']);
- if (empty($latest)) return $params['goods_id'];
- $goods = self::lists([
- 'where' => [['mall_id' => $mall_id], ['community_id' => $latest['community_id']], ['status' => StatusEnum::ENABLED]],
- 'select' => 'id, goods_id'
- ]);
- $exsit_goods_id = array_column($goods, 'goods_id');
- $exsit_goods_id = $exsit_goods_id ?? [];
- if ($exsit_goods_id) {
- $goods_setting = CommunityGoodsSetting::lists([
- 'where' => [['mall_id' => $mall_id], ['goods_id' => $exsit_goods_id], ['status' => StatusEnum::ENABLED], ['enable' => StatusEnum::ENABLED]],
- 'select' => 'goods_id'
- ]);
- $exsit_goods_id = array_column($goods_setting, 'goods_id');
- $exsit_goods_id = $exsit_goods_id ?? [];
- }
- return $exsit_goods_id;
- }
- /**
- * @Description: 订单预览追加字段
- * @Author: zsan
- * @DateTime 2023-02-16 09:36:11
- * @param array $params
- * @return array
- */
- public function orderPreviewAppendFields($params)
- {
- $input = $params['params'];
- $response = $params['data'];
- $mall_id = $params['mall_id'];
- $user_id = $params['user_id'];
- $latitude = $input['latitude'];
- $longitude = $input['longitude'];
- $type = $input['type'];
- $need_not_express = $input['need_not_express'];
- $location_style = $input['location_style'] ?? 1;
- if (!in_array($type, [PreviewTypeEnum::CART, PreviewTypeEnum::BUY_NOW])) return $response;
- if (!in_array($location_style, [3])) return $response;
- $attr_ids = [];
- if ($type == PreviewTypeEnum::CART) {
- // 购物车操作
- $attr_ids = $input['attr_ids'];
- } else {
- // 直接购买
- $attr_ids = $input['attr_id'];
- }
- $goods_attr = GoodsAttr::lists([
- 'where' => [
- ['status' => StatusEnum::ENABLED], ['id' => $attr_ids]
- ],
- 'select' => 'id, goods_id',
- 'with' => [
- 'goods' => function ($query) {
- $query->select('id, goods_type');
- }
- ],
- ]);
- $goods_type = GoodsTypeEnum::GoodsTypePhysical;
- foreach ($goods_attr as $v) {
- if ($v['goods']['goods_type'] == GoodsTypeEnum::GoodsTypeVirtual) {
- $goods_type = GoodsTypeEnum::GoodsTypeVirtual;
- break;
- }
- }
- if ($goods_type == GoodsTypeEnum::GoodsTypeVirtual) {
- return $response;
- }
- $response['option_list'] = ShippingTypeEnum::getBaseShippingType();
- $goods_ids = array_column($goods_attr, 'goods_id');
- $goods_ids = $goods_ids ?? [];
- if (empty($goods_ids)) return $response;
- $first_goods_id = $goods_ids[0];
- $goods_setting = self::lists([
- 'where' => [
- ['mall_id' => $mall_id], ['goods_id' => $goods_ids], ['status' => StatusEnum::ENABLED]
- ],
- 'select' => 'id, goods_id, community_id'
- ]);
- $community_ids = array_column($goods_setting, 'community_id');
- $supported_logistics = [];
- $enable_goods_setting = [];
- if ($goods_setting) {
- $enable_goods_setting = CommunityGoodsSetting::lists([
- 'where' => [['mall_id' => $mall_id], ['goods_id' => array_column($goods_setting, 'goods_id') ?? []], ['status' => StatusEnum::ENABLED], ['enable' => StatusEnum::ENABLED]],
- 'select' => 'id, supported_logistics, goods_id',
- ]);
- if ($enable_goods_setting) {
- foreach ($enable_goods_setting as $item) {
- $supported_logistics_item = json_decode($item['supported_logistics'], true);
- // 当前没有数据加入初始化数据
- if (empty($supported_logistics)) {
- $supported_logistics = $supported_logistics_item;
- } else {
- // 判断两个数组是否有交集
- $supported_logistics = array_intersect($supported_logistics, $supported_logistics_item);
- if (empty($supported_logistics)) {
- // 当前数组没有交集
- throw new Exception('部分商品属性不同无法一起下单,请您分开下单操作。');
- }
- }
- }
- $enable_goods_setting = array_column($enable_goods_setting, null, 'goods_id');
- }
- }
- if (empty($enable_goods_setting) && $need_not_express) {
- $response['option_list'] = [];
- $response['is_address'] = 0;
- }
- // 如果设置社区不为空并且其中有自提点
- if (!empty($supported_logistics) && in_array(ShippingTypeEnum::PICKUP, $supported_logistics)) {
- // 判断所选的多商品中社区地址是否有相同
- $community_unique = array_unique($community_ids); // 去除订单中重复地址ID
- $goods_ids_unique = array_unique($goods_ids);
- if ((count($community_unique) == count($community_ids)) && count($goods_ids_unique) > 1) {
- // 社区地址没有重复(那么多个社区团购订单无法进行一致地址则提示客户重新选择相同地址商品)
- throw new Exception('部分商品不支持当前自提点,切换自提点或单独下单。');
- }
- }
- $supported_logistics_methods = [
- ShippingTypeEnum::LOGISTICS => ['key' => ShippingTypeEnum::LOGISTICS, 'name' => '快递配送', 'enable' => 1],
- ShippingTypeEnum::PICKUP => ['key' => ShippingTypeEnum::PICKUP, 'name' => '站点自提', 'enable' => 1],
- ShippingTypeEnum::MERCHANT_DISTRIBUTION => ['key' => ShippingTypeEnum::MERCHANT_DISTRIBUTION, 'name' => '送货上门', 'enable' => 1]
- ];
- $latest = self::getLatestCommunityOne($mall_id, $user_id);
- $latest_logistics_methods = [];
- $community_goods_ids = array_column($goods_setting, 'goods_id');
- foreach ($supported_logistics_methods as $item) {
- if (in_array($item['key'], $supported_logistics)) {
- if (!in_array($first_goods_id, $community_goods_ids) || !isset($enable_goods_setting[$first_goods_id])) {
- $item['enable'] = 0;
- }
- if (!empty($latest) && $item['key'] != ShippingTypeEnum::LOGISTICS && !in_array($latest['community_id'], $community_ids)) {
- $item['enable'] = 0;
- }
- // 如果商品独立设置的自提区域有选中。但是社区团购区域配置已经去除该区域。则该区域不可用
- if (!empty($latest) && !empty($latest['community']) && !empty($item['key']) && $item['key'] == ShippingTypeEnum::PICKUP) {
- $setting_service = new SettingService();
- $area = $setting_service->getFieldSetting($mall_id, 'area', true);
- $area = json_decode($area, true);
- if (!empty($area) && !in_array($latest['community']['district_id'], $area)) {
- $item['enable'] = 0;
- }
- }
- if ($item['enable'] == 1) {
- if (!empty($latest) && $item['key'] == ShippingTypeEnum::MERCHANT_DISTRIBUTION && $latest['community']['is_home_delivery'] == 0) {
- $item['enable'] = 0;
- }
- }
- array_push($latest_logistics_methods, $item);
- }
- }
- if ($latest_logistics_methods) {
- unset($response['option_list']);
- $response['option_list'] = $latest_logistics_methods;
- }
- $extends_fields = [];
- $extends_fields[CommunityEnum::ADDONS_NAME] = [
- 'is_selected' => 0, //是否有选择自提点
- 'community_info' => [], //自提点信息
- 'distance' => 0, //距离
- 'pickup_time' => '', //提货时间文案
- ];
- if ($latest) $extends_fields[CommunityEnum::ADDONS_NAME]['is_selected'] = 1;
- if (isset($latest['community'])) {
- $extends_fields[CommunityEnum::ADDONS_NAME]['community_info'] = $latest['community'];
- $location_obj = new LocationHelper();
- $distance = $location_obj->getDistanceByGeo($latest['community']['latitude'], $latest['community']['longitude'], $latitude, $longitude);
- $extends_fields[CommunityEnum::ADDONS_NAME]['distance'] = bcmul(bcmul($distance, 1000, 4), 1, 1);
- $config = (new SettingService())->get($mall_id);
- $position_range = bcmul($config['position_range'], 1000, 1);
- $extends_fields[CommunityEnum::ADDONS_NAME]['distance'] = bcmul(bcmul($distance, 1000, 4), 1, 1);
- if ($position_range < $extends_fields[CommunityEnum::ADDONS_NAME]['distance']) {
- // 需要去掉 自提,上门两个选项
- foreach ($response['option_list'] as &$vItem) {
- if (in_array($vItem['key'], [2,3])) {
- $vItem['enable'] = 0;
- }
- }
- }
- $extends_fields[CommunityEnum::ADDONS_NAME]['pickup_time'] = CommunityHelper::getPickUpAt($mall_id, time()) . '可取货';
- }
- $response['extends_fields'] = array_merge($response['extends_fields'] ?? [], $extends_fields);
- return $response;
- }
- /**
- * 创建订单时检查对应商品自提点是否有相同门店
- * @param array $params
- * @return mixed
- * @throws Exception
- */
- public static function checkCommunityGoods(array $params)
- {
- try {
- $paramsInput = $params['params'];
- $mall_id = $params['mall_id'];
- $user_id = $params['user_id'];
- $type = $paramsInput['type'];
- if ($type == PreviewTypeEnum::CART) {
- // 购物车操作
- $attr_ids = $paramsInput['attr_ids'];
- } else {
- // 直接购买
- $attr_ids = $paramsInput['attr_id'];
- }
- $goods_attr = GoodsAttr::lists([
- 'where' => [
- ['status' => StatusEnum::ENABLED], ['id' => $attr_ids]
- ],
- 'select' => 'id, goods_id',
- 'with' => [
- 'goods' => function ($query) {
- $query->select('id, goods_type');
- }
- ],
- ]);
- $goods_ids = array_column($goods_attr, 'goods_id') ?? [];
- if (!empty($goods_ids)) {
- $goods_setting = self::lists([
- 'where' => [
- ['mall_id' => $mall_id], ['goods_id' => $goods_ids], ['status' => StatusEnum::ENABLED]
- ],
- 'select' => 'id, goods_id, community_id'
- ]);
- $community_ids = array_column($goods_setting, 'community_id');
- $latest = self::getLatestCommunityOne($mall_id, $user_id);
- // 当选择自提点时如果选中的商品没有在当前自提点门店则提示客户不支持自提
- $shipping_type = $paramsInput['shipping_type'];
- if ($shipping_type == ShippingTypeEnum::PICKUP && !empty($goods_setting)) {
- // 获取当前商品自提点
- $is_pickup_point = false;
- // 当为多商品时
- if (count($goods_ids) > 1 && !empty($community_ids)) {
- $goods_unique_ids = array_unique($goods_ids);
- foreach (array_count_values($community_ids) as $key => $item) {
- if (($item > 1 || count($goods_unique_ids) == 1) && $key == $latest['community_id']) {
- $is_pickup_point = true;
- break;
- }
- }
- } else {// 如果为单商品
- $is_pickup_point = in_array($latest['community_id'], $community_ids);
- }
- if (!$is_pickup_point) {
- self::$static_error = '部分商品不支持当前自提点,切换自提点或单独下单。';
- return false;
- }
- }
- }
- } catch (Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- return true;
- }
- public function cartListAppendFields($params)
- {
- $data = $params['data'];
- if (empty($data)) return $data;
- $mall_id = $params['mall_id'];
- $user_id = $params['user_id'];
- $location_style = $params['location_style'] ?? 1;
- $latest_one = self::getLatestCommunityOne($mall_id, $user_id);
- foreach ($data as $k => $v) {
- $list = $v['list'];
- // 商城订单
- if ($k == 0) {
- $goods_ids = array_column($list, 'goods_id');
- $goods_setting = CommunityGoodsSetting::lists(['where' => [['mall_id' => $mall_id], ['goods_id' => $goods_ids], ['status' => StatusEnum::ENABLED], ['enable' => StatusEnum::ENABLED]], 'select' => 'supported_logistics, goods_id', 'index' => 'goods_id']);
- $goods_ids = array_column($goods_setting, 'goods_id') ?? [];
- $community_goods = CommunityGoods::lists(
- [
- 'where' => [['mall_id' => $mall_id], ['goods_id' => $goods_ids], ['status' => StatusEnum::ENABLED], ['community_id' => $latest_one['community_id'] ?? 0],],
- 'select' => 'goods_id',
- 'index' => 'goods_id'
- ]
- );
- foreach ($list as &$val) {
- $params['mall_id'] = $mall_id;
- $params['user']['id'] = $user_id;
- $params['goods']['id'] = $val['goods_id'];
- $result = self::getApiGoodsDetail($params);
- $val['is_community'] = $result['goods']['is_community'];
- $val['supported_logistics'] = [1];
- $val['is_supported_pickup'] = 0;
- if ($location_style == 3) {
- isset($goods_setting[$val['goods_id']]) && $val['supported_logistics'] = json_decode($goods_setting[$val['goods_id']]['supported_logistics'], true);
- isset($community_goods[$val['goods_id']]) && $val['is_supported_pickup'] = 1;
- }
- }
- unset($val);
- } else {
- // 多商户插件订单
- foreach ($list as &$val) {
- $val['supported_logistics'] = [1];
- $val['is_supported_pickup'] = 0;
- }
- unset($val);
- }
- $data[$k]['list'] = $list;
- }
- return $data;
- }
- public static function getComponentData($params, $mall_id)
- {
- $params['type'] = $params['type'] ?? 'goods';
- // 导航风格,3表示自提点风格
- $location_style = $params['location_style'] ?? 1;
- $community_id = $params['community_id'] ?? 0;
- switch ($params['type']) {
- case 'goods':
- $goods_ids = [];
- if ($location_style != 3) {
- $goods_ids = Json::decode($params['id'], true);
- } else {
- if (!empty($community_id)) {
- $goods_setting = CommunityGoods::lists(['where' => [['mall_id' => $mall_id], ['community_id' => $params['community_id']], ['status' => StatusEnum::ENABLED]], 'select' => 'goods_id']);
- $goods_ids = array_column($goods_setting, 'goods_id') ?? [];
- if ($goods_ids) {
- $enable_goods_setting = CommunityGoodsSetting::lists(['where' => [['mall_id' => $mall_id], ['goods_id' => $goods_ids], ['status' => StatusEnum::ENABLED], ['enable' => StatusEnum::ENABLED]], 'select' => 'goods_id']);
- $goods_ids = array_column($enable_goods_setting, 'goods_id') ?? [];
- }
- }
- $origin_goods_ids = Json::decode($params['id'], true);
- $goods_ids = array_intersect($origin_goods_ids, $goods_ids);
- }
- break;
- case 'goods_cate':
- $cate_id_arr = [$params['id']];
- $goods_cate_relate_list = GoodsCateRelate::findAll(['cate_id' => $cate_id_arr]);
- $goods_ids = array_column($goods_cate_relate_list, 'goods_id') ?? [];
- if ($location_style == 3 && !empty($community_id)) {
- $goods_setting = CommunityGoods::lists(['where' => [['mall_id' => $mall_id], ['goods_id' => $goods_ids], ['community_id' => $params['community_id']], ['status' => StatusEnum::ENABLED]], 'select' => 'goods_id']);
- $goods_ids = array_column($goods_setting, 'goods_id') ?? [];
- if ($goods_ids) {
- $enable_goods_setting = CommunityGoodsSetting::lists([
- 'where' => [['mall_id' => $mall_id], ['goods_id' => $goods_ids], ['status' => StatusEnum::ENABLED], ['enable' => StatusEnum::ENABLED]],
- 'select' => 'goods_id'
- ]);
- $goods_ids = array_column($enable_goods_setting, 'goods_id') ?? [];
- }
- }
- break;
- default:
- break;
- }
- $goods_params = ['where' => [['=', 'mall_id', $mall_id], ['in', 'id', $goods_ids], ['=', 'status', StatusEnum::ENABLED], ['=', 'is_on_sale', StatusEnum::ENABLED]], 'select' => 'id,goods_name,subtitle,price,original_price,cover_pic,(sales_num+virtual_sales) as sales_num, is_attr', 'index' => 'id'];
- if (isset($params['limit'])) {
- $goods_params['limit'] = $params['limit'];
- $goods_params['page'] = 1;
- }
- return Goods::lists($goods_params, true);
- }
- public static function getLatestCommunityOne($mall_id, $user_id)
- {
- return CommunityUser::getOne(
- [['mall_id' => $mall_id], ['user_id' => $user_id], ['status' => StatusEnum::ENABLED], ['is_checked' => StatusEnum::ENABLED]],
- true,
- ['community' => function ($query) {
- return $query->select('id,address,latitude,longitude,name,logo,is_home_delivery, province_id, city_id, district_id')->andWhere(['status' => StatusEnum::ENABLED]);
- }],
- 'id desc',
- 'id,user_id,community_id'
- );
- }
- // 是否社区团购
- public static function getApiGoodsDetail($params)
- {
- $is_community = 0;
- if (MallAddons::isInstall($params['mall_id'], AddonsEnum::ADDONS_NAME_COMMUNITY) && !empty($params['user']['id']) && !empty($params['goods']['id'])) {
- $CommunityInfo = CommunityGoodsSetting::findOne(['mall_id' => $params['mall_id'], 'goods_id' => $params['goods']['id'], 'status' => [StatusEnum::ENABLED], 'enable' => [StatusEnum::ENABLED]]);
- if (!empty($CommunityInfo)) {
- $is_community = 1;
- }
- }
- $params['goods']['is_community'] = $is_community;
- return $params;
- }
- }
|