| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 |
- <?php
- namespace addons\Happiness\common\models;
- use addons\Happiness\common\models\HappinessStoreAdmin;
- use addons\Happiness\common\enums\HappinessEnum;
- use addons\Store\common\models\StoreAssociatedUser;
- use addons\Store\common\models\StoreCommission;
- use addons\Store\common\models\StoreMerchantReduceProfit;
- use addons\Store\common\models\StoreOrder;
- use addons\Store\common\models\StoreOrderDetail;
- use addons\Store\common\models\StoreSettings;
- use addons\Store\common\models\StoreStatistics;
- use common\enums\AddonsEnum;
- use common\enums\OrderStatusEnum;
- use common\enums\PayTypeEnum;
- use common\enums\StatusEnum;
- use common\enums\UserWalletEnum;
- use common\models\base\BaseActiveRecord;
- use common\models\common\CapitalLog;
- use common\models\mall\Mall;
- use common\models\mall\MallAddons;
- use common\models\order\Order;
- use common\models\user\User;
- use services\common\UserWalletService;
- use Yii;
- use yii\console\ExitCode;
- use yii\db\Exception;
- /**
- * This is the model class for table "qimall_addons_happiness_store".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $user_id 绑定会员id
- * @property string $shop_owner 店长姓名
- * @property string $shop_mobile 店长手机号
- * @property string $store_name 门店名称
- * @property string $store_desc 门店简介
- * @property string $logo_img 门店logo
- * @property string $store_img 门店图片
- * @property string $license_img 营业执照
- * @property int|null $province_id 省
- * @property int|null $city_id 市
- * @property int|null $district_id 区
- * @property string $address 详细地址
- * @property int $expire_time 失效时间,0代表无限期
- * @property float $total_money 累计收入
- * @property float $share_amount 累计收入
- * @property float $balance 当前余额
- * @property float $frozen_balance 冻结余额
- * @property float $total_expenses 累计支出
- * @property int|null $user_nums 会员总数
- * @property string $longitude 经度
- * @property string $latitude 维度
- * @property int $check_status 审核状态:0:待审核;1:已通过;2:未通过
- * @property string $check_remark 审核备注
- * @property string $business_time_start 营业时间开始
- * @property string $business_time_end 营业时间结束
- * @property string $freight_type 配送设置
- * @property string $intra_city_distribution 同城配送
- * @property float $total_order_money 订单总金额
- * @property int $refund_money 退款金额
- * @property float $refund_num 退款订单数量
- * @property float $fine_money 罚款金额
- * @property int $total_num 总数
- * @property float $total_settled_amount 已结算总金额
- * @property float $unsettled_amount 未结算金额
- * @property int $sales_volume 销量
- * @property int $no 编号
- * @property int $merchant_distribution 商家配送
- * @property float $praise 评分
- * @property int $status 状态[0禁用 1启用 -1删除]
- * @property int $shop_status 门店营业状态,1:正在营业;0:休息中
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- * @property int $business_id 业务员ID
- * @property string $huifu_no 汇付号
- */
- class HappinessStore extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_happiness_store}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'province_id', 'city_id', 'district_id','street_id','expire_time', 'user_nums',
- 'total_num', 'sales_volume', 'status', 'shop_status', 'created_at', 'updated_at', 'merchant_distribution', 'self_mention', 'is_alone','business_id','check_status'], 'integer'],
- [['total_money', 'balance','frozen_balance','refund_money','refund_num', 'fine_money', 'total_expenses', 'total_order_money', 'total_settled_amount', 'unsettled_amount', 'praise', 'share_amount', 'distribution_scope'], 'number'],
- [['shop_owner', 'store_name', 'store_desc', 'logo_img', 'license_img', 'address', 'longitude', 'latitude',
- 'business_time_start', 'business_time_end','check_remark'], 'string', 'max' => 255],
- [['huifu_no'], 'string', 'max' => 100],
- [['intra_city_distribution','no'], 'string', 'max' => 500],
- [['shop_mobile'], 'string', 'max' => 11],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => '绑定会员id',
- 'no' => '编号',
- 'business_id'=>'业务员ID',
- 'shop_owner' => '店长姓名',
- 'shop_mobile' => '店长手机号',
- 'store_name' => '门店名称',
- 'store_desc' => '门店简介',
- 'logo_img' => '门店logo',
- 'license_img' => '营业执照',
- 'province_id' => '省',
- 'city_id' => '市',
- 'district_id' => '区',
- 'street_id' => '街道',
- 'community_id' => '社区',
- 'address' => '详细地址',
- 'expire_time' => '失效时间,0代表无限期',
- 'total_money' => '累计收入',
- 'balance' => '当前余额',
- 'frozen_balance' => '冻结余额',
- 'total_expenses' => '累计支出',
- 'user_nums' => '会员总数',
- 'longitude' => '经度',
- 'latitude' => '维度',
- 'check_status' => '审核状态:0:待审核;1:已通过;2:未通过',
- 'check_remark' => '审核备注',
- 'business_time_start' => '营业时间开始',
- 'business_time_end' => '营业时间结束',
- 'freight_type' => '配送设置',
- 'intra_city_distribution' => '同城配送',
- 'total_order_money' => '订单总金额',
- 'total_num' => '总数',
- 'total_settled_amount' => '已结算总金额',
- 'unsettled_amount' => '未结算金额',
- 'refund_money' => '退款金额',
- 'refund_num'=>'退款订单数量',
- 'file_money' => '罚款金额',
- 'status' => '状态[0禁用 1启用 -1删除]',
- 'shop_status' => '门店营业状态',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- ];
- }
- public static function setData(array $params, bool $is_custom_pwd = false)
- {
- $t = Yii::$app->db->beginTransaction();
- try {
- if (!empty($params['id'])) {
- $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (empty($model)) throw new \Exception('门店不存在或已删除');
- } else {
- $model = new self();
- $model->loadDefaultValues();
- // $model->expire_time = strtotime("+1 year");
- }
- // if (!empty($params['freight_type'])) $params['freight_type'] = json_encode($params['freight_type']);
- if (!empty($params['intra_city_distribution'])) $params['intra_city_distribution'] = json_encode($params['intra_city_distribution']);
- if (!$model->load($params, '') || !$model->save()) {
- throw new \Exception($model->getErrorMessage());
- }
- $store_addmin = HappinessStoreAdmin::findOne(['mall_id' => $params['mall_id'], 'store_id' => $model->id, 'status' => StatusEnum::ENABLED]);
- // 同步一下账号
- if ($store_addmin) {
- if ($model->shop_mobile != $store_addmin->username) {
- $pwd_str = substr($model->shop_mobile, -6);
- if ($is_custom_pwd) $pwd_str = $params['password'];
- $pwd_hash_str = \Yii::$app->security->generatePasswordHash($pwd_str);
- $store_addmin->username = $model->shop_mobile;
- $store_addmin->password = $pwd_hash_str;
- if (!$store_addmin->save()) throw new \Exception($store_addmin->getErrorMessage());
- }
- }
-
- $t->commit();
- return $model;
- } catch (\Exception $e) {
- $t->rollBack();
- self::$static_error = $e->getMessage() . $e->getLine() . $e->getFile();
- return false;
- }
- }
- /**
- * @param array $params
- * @param \Closure|null $callback
- * @param bool $is_custom_pwd //是否自定义密码
- * @return bool {*}
- * @throws Exception
- * @throws \yii\base\Exception
- * @msg: 添加一个门店,同时添加门店后台的管理员。默认账号是门店绑定手机号,默认登录密码是手机号后六位
- */
- public static function addStore(array $params, \Closure $callback = null, bool $is_custom_pwd = false)
- {
- //查询业务员
- $business = User::find()
- ->andWhere(['mall_id' => $params['mall_id']])
- ->andWhere([
- 'or',
- ['id' => $params['business_id']],
- ['mobile' => $params['business_id']]
- ])
- ->one();
- if(empty($business))
- {
- self::$static_error = '推广员不存在';
- return false;
- }
- $business=HappinessBusiness::find()->where(['mall_id' => $params['mall_id'], 'user_id' => $business->id])
- ->one();
- if(empty($business))
- {
- self::$static_error = '用户'.$business->id.'不是推广员';
- return false;
- }
- $params['business_id'] = $business->user_id;
- $transaction = \Yii::$app->db->beginTransaction();
- $res = self::setData($params, $is_custom_pwd);
- if (false === $res) {
- $transaction->rollBack();
- return false;
- }
- $pwd_str = substr($params['shop_mobile'], -6);
- if ($is_custom_pwd) $pwd_str = $params['password'];
- $pwd_hash_str = \Yii::$app->security->generatePasswordHash($pwd_str);
- $admin_info = [
- 'username' => $params['shop_mobile'],
- 'account' => $params['shop_owner'],
- 'password' => $pwd_hash_str,
- 'mall_id' => $params['mall_id'],
- 'admin_type' => 2,
- 'status' => StatusEnum::ENABLED,
- 'user_id' => $params['user_id'],
- 'store_id' => $res->id,
- ];
- $admin_model = HappinessStoreAdmin::find()
- ->where(['mall_id' => $params['mall_id'], 'status' => StatusEnum::ENABLED, 'username' => $params['shop_mobile']])
- ->one();
- if (!empty($admin_model) && $admin_model['store_id'] != $res->id) {
- $transaction->rollBack();
- self::$static_error = '门店管理员账号已经存在';
- return false;
- }
- $admin_model = new HappinessStoreAdmin();
- $admin_model->loadDefaultValues();
- $admin_model->attributes = $admin_info;
- $admin_model->updated_at = time();
- $admin_model->created_at = time();
- $res_ad = $admin_model->save();
- if (false === $res_ad) {
- $transaction->rollBack();
- self::$static_error = $admin_model->getErrorMessage();
- return false;
- }
- // 小店入驻新增参数(斗拱银行卡信息)
- $cardInfoField = ['card_type','card_name','card_no','prov_id','area_id','branch_code','cert_type','cert_no','cert_validity_type','cert_begin_date','cert_end_date','mp','is_settle_default'];
- $cardInfoInsert = [];
- foreach ($cardInfoField as $field) {
- $cardInfoInsert[$field] = $params[$field] ? $params[$field] : 0;
- }
- $cardInfoInsert['store_id'] = $res->id;
- // $cardInfoInsert = [
- // 'card_type' => 2,
- // 'card_name' => '史晨',
- // 'card_no' => 6212260200076546403,
- // 'prov_id' => 1,
- // 'area_id' => 1,
- // 'branch_code' => '',
- // 'cert_type' => '00',
- // 'cert_no' => '371481199602054512',
- // 'cert_validity_type' => '',
- // 'cert_begin_date' => 20250922,
- // 'cert_end_date' => 20350922,
- // 'mp' => 18600648353,
- // 'is_settle_default' => 'Y',
- // 'store_id' => 23
- // ];
- $storeCardModel = new HappinessStoreCardInfo();
- $storeCardModel->attributes = $cardInfoInsert;
- $cardInfoRes = $storeCardModel->save();
- if (false === $cardInfoRes){
- $transaction->rollBack();
- self::$static_error = $storeCardModel->getErrorMessage();
- return false;
- }
- $transaction->commit();
- return $res;
- }
- public static function saveStoreSetting(int $mall_id, array $data, array $addons_settings = [])
- {
- $transaction = \Yii::$app->db->beginTransaction();
- $store_info = [
- 'shop_status' => $data['shop_status'],
- 'shop_mobile' => $data['username'],
- 'business_time_start' => $data['business_time_start'],
- 'business_time_end' => $data['business_time_end'],
- 'id' => $data['store_id'],
- 'mall_id' => $mall_id,
- 'intra_city_distribution' => $data['intra_city_distribution'] ?? [],
- 'merchant_distribution' => $data['merchant_distribution'],
- 'self_mention' => $data['self_mention'],
- 'is_alone' => $data['is_alone'],
- 'distribution_scope' => $data['distribution_scope'],
- ];
-
- $store_res = self::setData($store_info);
- if (false === $store_res) {
- $transaction->rollBack();
- self::$static_error = self::getStaticError();
- return false;
- }
- //判断门店是否存在
- $admin_model = HappinessStoreAdmin::findOne(['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED, 'username' => $store_res->shop_mobile]);
- if (empty($admin_model)) {
- $transaction->rollBack();
- self::$static_error = '门店管理员账号不存在';
- return false;
- }
- // 因为上一步已经有账号变更现在只要密码变更就行
- if (!empty($data['password'])) {
- $admin_model->password = \Yii::$app->security->generatePasswordHash($data['password']);
- $admin_model->updated_at = time();
- $admin_res = $admin_model->save();
- if (empty($admin_res)) {
- $transaction->rollBack();
- self::$static_error = $admin_model->getErrorMessage();
- return false;
- }
- }
- $transaction->commit();
- return true;
- }
- /**
- * @name:
- * @msg: 装修页面获取门店列表
- * @param {int} $mall_id
- * @param {array} $params
- * @return {*}
- */
- public static function getStoreListInDiy(int $mall_id, array $params = [])
- {
- $wheres[] = ['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED];
- if (!empty($params['store_id'])) {
- $wheres[] = ['id' => $params['store_id']];
- }
- if (!empty($params['store_name'])) {
- $wheres[] = ['like', 'store_name', $params['store_name']];
- }
- if (!empty($params['storeowner'])) {
- $wheres[] = ['like', 'shop_owner', $params['storeowner']];
- }
- $params = [
- 'select' => '*,store_name as title,logo_img as img',
- 'where' => $wheres,
- 'order' => 'created_at desc',
- ];
- $store_list = self::listPage($params);
- if (false === $store_list) {
- return false;
- }
- return $store_list;
- }
- //获取门店更多
- public static function MoreStore(string $storeList, int $mall_id)
- {
- $params = [
- 'select' => '*,store_name as title,logo_img as img',
- 'where' => "id in ($storeList) and status = 1 and check_status = 1 and mall_id = $mall_id and shop_status = 1",
- 'order' => 'created_at desc',
- ];
- $store_list = self::listpage($params);
- if (false === $store_list) {
- return false;
- }
- $decoration = \Yii::$app->services->setting->addons->get($mall_id, HappinessEnum::ADDONS_NAME, 'decoration');
- foreach ($store_list['list'] as &$item) {
- if (!empty($decoration['custom_store_style'])) {
- $item['store_style'] = $item['show_style'] ?? 1;
- } else {
- $item['store_style'] = $decoration['default_store_style'] ?? 1;
- }
- }
- return $store_list;
- }
- /**
- * 结算货款
- *
- * @param int $order_id
- * @param int $store_id
- * @param string $order_no
- * @param integer $is_settlement 是否已经结算订(用于虚拟订单直接结算, 虚拟订单生成的佣金记录是已结算的,所以需要传1查询)
- * @return void
- */
- public static function settlementStoreCommission($order_id, $store_id, $order_no, $is_settlement = 0)
- {
- $store = \addons\Store\common\models\Store::findOne(['id' => $store_id]);
- $store_commission_model = StoreCommission::findOne(['order_no' => $order_no, 'is_settlement' => $is_settlement, 'status' => StatusEnum::ENABLED]);
- if ($store_commission_model) {
- // 配置信息
- $storeSetting = StoreSettings::findOne(['store_id' => $store->id]);
- $order = StoreOrder::findOne(['id' => $order_id]);
- if ($storeSetting->store_service_fee == 2 && MallAddons::isInstall($store->mall_id, AddonsEnum::ADDONS_NAME_HUIFU_PAY) && $order->payment_type == PayTypeEnum::HUIFUPAY) {
- $store->share_amount += $store_commission_model->amount_received; // 已分帐金额
- } else {
- $store->balance += $store_commission_model->amount_received; // 余额
- $store->total_settled_amount += $store_commission_model->amount_received; // 已结算总金额
- }
- $store->unsettled_amount -= $store_commission_model->amount_received; // 未结算
- if ($store->unsettled_amount < 0) $store->unsettled_amount = 0;
- $res = $store->save();
- if ($res == false) throw new Exception('o2o订单完成结算货款,更新店铺结算金额失败,order_no:' . $order_no);
- $store_commission_model->is_settlement = 1;
- $res = $store_commission_model->save();
- if ($res == false) throw new Exception('o2o订单完成结算货款,更新提成记录失败,order_no:' . $order_no);
- StoreStatistics::updateIncomeMoney($store, $store_commission_model->amount_received);
- $key = HappinessEnum::STORE_NOT_SETTLE_AMOUNTS . ':' . $store['mall_id'];
- $res = Yii::$app->redis->get($key);
- $amount_received_temp = $store_commission_model->amount_received;
- if (!empty($res)) $amount_received_temp = bcsub($res, $store_commission_model->amount_received, 2);
- if ($amount_received_temp < 0) $amount_received_temp = 0;
- Yii::$app->redis->set($key, $amount_received_temp);//待结算
- $amount_received_temp = $store_commission_model->amount_received;
- $key = HappinessEnum::STORE_SETTLE_AMOUNTS . ':' . $store['mall_id'];
- $res = \Yii::$app->redis->get($key);
- if (!empty($res)) $amount_received_temp = bcadd($res, $store_commission_model->amount_received, 2);
- Yii::$app->redis->set($key, $amount_received_temp);//已结算
- //结算积分
- if (!empty($store_commission_model['score_deduction_bear']) && $store_commission_model['score_deduction_bear'] == 1) {
- self::settlementScore($order_no, $store['user_id'], $store_commission_model['id']);
- }
- }
- }
- /**
- * 结算积分
- * @param $order_no
- * @param $store_user_id
- * @param $source_table_id
- * @return void
- */
- public static function settlementScore($order_no, $store_user_id, $source_table_id)
- {
- $store_order = StoreOrder::findOne(['order_no' => $order_no]);
- $store_order_detail_list = StoreOrderDetail::find()->where(['order_id' => $store_order['id'], 'is_feedback' => 0])->all();
- $order_detail_ids = array_column($store_order_detail_list, 'id');
- $source_table = StoreOrderDetail::tableName();
- CapitalLog::$capitalType = 'score';
- $score_frozen_log_list = CapitalLog::lists(
- [
- 'where' => [
- ['user_id' => $store_order['user_id']],
- ['change_type' => 'sub'],
- ['source_table' => $source_table],
- ['source_table_id' => $order_detail_ids],
- ['from_type' => UserWalletEnum::CONSUME],
- ['capital_type' => 'consume_store_order'],
- ]
- ]
- );
- if (!empty($score_frozen_log_list)) {
- $received_score = array_sum(array_column($score_frozen_log_list, 'change_num'));
- if ($received_score > 0) {
- $desc = '门店订单:' . $order_no . ':积分结算' . $received_score;
- $data = [
- 'message_id' => 0,
- 'mall_id' => $store_order['mall_id'],
- 'user_id' => $store_user_id,
- 'wallet_type' => 'score',
- 'is_frozen' => false,
- 'unfrozen' => false,
- 'money' => $received_score,
- 'desc' => $desc,
- 'source_table' => StoreCommission::tableName(),
- 'source_table_id' => $source_table_id,
- 'from_type' => AddonsEnum::ADDONS_NAME_STORE,
- 'capital_type' => 'consume_store_order',
- 'order_no' => $order_no
- ];
- UserWalletService::handle(0, $data);
- }
- }
- }
- /**
- * 通过ID获取手机号码
- *
- * @param integer $id
- * @return string|null
- */
- public static function getMobileById(int $mall_id, int $id)
- {
- return static::find()
- ->where(['mall_id' => $mall_id, 'id' => $id])
- ->select('shop_mobile')
- ->scalar();
- }
- public static function delStore($mall_id, $store_id)
- {
- $store = self::findOne(['id' => $store_id, 'mall_id' => $mall_id, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (empty($store)) throw new \Exception('门店不存在');
- if ($store['balance'] > 0) throw new \Exception('店铺余额不为0,请先提现后再删除');
- $where = [
- ['yo.mall_id' => $mall_id],
- ['yo.store_id' => $store_id],
- ['o.order_status' => [OrderStatusEnum::PAY, OrderStatusEnum::SHIPMENTS, OrderStatusEnum::SING, OrderStatusEnum::TAKE]],
- ];
- $alias = 'yo';
- $order = "id desc";
- $join = [['LEFT JOIN', Order::tableName(). ' as o', "o.id = yo.order_id"]];
- $select = 'o.*,yo.store_id';
- $params = compact('where', 'order', 'alias', 'join', 'select');
- $store_order = HappinessOrder::lists($params);
- if (!empty($store_order)) throw new \Exception('请等订单完成后再删除');
- $t = Yii::$app->db->beginTransaction();
- try {
- $store->status = StatusEnum::DELETE;
- $res = $store->save();
- if (empty($res)) throw new \Exception('删除失败');
- HappinessStoreAdmin::updateAll(['status' => StatusEnum::DELETE], ['store_id' => $store_id, 'mall_id' => $mall_id]);
- //删除门店关联的核销员
- HappinessClerk::updateAll(['Status' => StatusEnum::DELETE], ['mall_id' => $mall_id, 'store_id' => $store_id]);
- // StoreAssociatedUser::updateAll(['status' => StatusEnum::DELETE], ['store_id' => $store_id, 'mall_id' => $mall_id]);
- $t->commit();
- } catch (\Exception $e) {
- $t->rollBack();
- throw new \Exception($e->getMessage());
- }
- return true;
- }
- public static function fixData()
- {
- $mall_list = Mall::getEnableMallList(true);
- $mall_ids = array_column($mall_list, 'id');
- if (empty($mall_ids)) {
- echo '没有可用商城,不做处理 ... ' . PHP_EOL;
- return ExitCode::UNSPECIFIED_ERROR;
- }
- foreach ($mall_ids as $mall_id) {
- $key = HappinessEnum::STORE_NOT_SETTLE_AMOUNTS . ':' . $mall_id;
- $not_settle_amounts = StoreCommission::find()->where(['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED, 'is_settlement' => 0])->sum('amount_received');
- if (empty($not_settle_amounts)) $not_settle_amounts = 0;
- \Yii::$app->redis->set($key, $not_settle_amounts);
- $key = HappinessEnum::STORE_SETTLE_AMOUNTS . ':' . $mall_id;
- $settle_amounts = StoreCommission::find()->where(['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED, 'is_settlement' => 1])->sum('amount_received');
- if (empty($settle_amounts)) $settle_amounts = 0;
- \Yii::$app->redis->set($key, $settle_amounts);
- var_dump($mall_id);
- }
- }
- /**
- * 门店自提码设置
- *
- * @param integer $store_id
- * @return array
- */
- public static function getStorePickup(int $store_id)
- {
- $pickup = static::find()
- ->where(['id' => $store_id])
- ->select('pickup')
- ->scalar();
- return empty($pickup) ? [] : json_decode($pickup, true);
- }
- public function getBusiness(){
- return $this->hasOne(User::class, ['id' => 'business_id']);
- }
- }
|