| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\client\models\v1;
- use yii\base\Model;
- class ShareCustomForm extends Model
- {
- public $store_id;
- public $data;
- public $store;
- public function rules()
- {
- return [
- [['data'], 'required'],
- [['data'], 'string'],
- ];
- }
- public function saveData()
- {
- if (!$this->validate()) {
- return $this->errorResponse;
- }
- Option::set('share_custom_data', $this->data, $this->store_id);
- return [
- 'code' => 0,
- 'msg' => '保存成功',
- ];
- }
- public function getData()
- {
- // TODO: 默认数据
- // $data = Option::get('share_custom_data', $this->store_id);
- $default_data = $this->getDefaultData();
- if (!$data) {
- $data = $default_data;
- } else {
- $data = json_decode($data, true);
- $data = $this->checkData($data, $default_data);
- }
- return [
- 'code' => 0,
- 'data' => $data,
- ];
- }
- //检查是否有新增的值
- public function checkData($list = array(), $default_list = array())
- {
- $ignore = ['menu'];
- $new_list = [];
- foreach ($default_list as $index => $value) {
- if (isset($list[$index])) {
- if (is_array($value) && !in_array($index, $ignore)) {
- $new_list[$index] = $this->checkData($list[$index], $value);
- } else {
- $new_list[$index] = $list[$index];
- }
- } else {
- $new_list[$index] = $value;
- }
- }
- return $new_list;
- }
- public function getDefaultData()
- {
- return [
- 'menus' => [
- 'money'=>[
- 'name' => '分销佣金',
- 'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/statics/images/share-custom/img-share-price.png',
- 'open_type' => 'navigator',
- 'url' => '/user/share-money/share-money',
- 'tel' => '',
- ],
- 'order'=>[
- 'name' => '分销订单',
- 'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/statics/images/share-custom/img-share-order.png',
- 'open_type' => 'navigator',
- 'url' => '/user/share-order/share-order',
- 'tel' => '',
- ],
- 'cash'=>[
- 'name' => '提现明细',
- 'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/statics/images/share-custom/img-share-cash.png',
- 'open_type' => 'navigator',
- 'url' => '/pages/cash-detail/cash-detail',
- 'tel' => '',
- ],
- 'team'=>[
- 'name' => '我的团队',
- 'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/statics/images/share-custom/img-share-team.png',
- 'open_type' => 'navigator',
- 'url' => '/user/share-team/share-team',
- 'tel' => '',
- ],
- 'qrcode'=>[
- 'name' => '推广二维码',
- 'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/statics/images/share-custom/img-share-qrcode.png',
- 'open_type' => 'navigator',
- 'url' => '/user/share-qrcode/share-qrcode',
- 'tel' => '',
- ],
- ],
- 'words' => [
- 'can_be_presented'=>[
- 'name' => '可提现佣金',
- 'default' => '可提现佣金',
- ],
- 'already_presented'=>[
- 'name' => '已提现佣金',
- 'default' => '已提现佣金',
- ],
- 'parent_name'=>[
- 'name' => '推荐人',
- 'default' => '推荐人',
- ],
- 'pending_money'=>[
- 'name' => '待打款佣金',
- 'default' => '待打款佣金',
- ],
- 'cash'=>[
- 'name' => '提现',
- 'default' => '提现',
- ],
- 'user_instructions'=>[
- 'name' => '用户须知',
- 'default' => '用户须知',
- ],
- 'apply_cash'=>[
- 'name' => '我要提现',
- 'default' => '我要提现',
- ],
- 'cash_type'=>[
- 'name' => '提现方式',
- 'default' => '提现方式',
- ],
- 'cash_money'=>[
- 'name' => '提现金额',
- 'default' => '提现金额',
- ],
- 'order_money_un'=>[
- 'name' => '未结算佣金',
- 'default' => '未结算佣金',
- ],
- 'share_name'=>[
- 'name' => '分销商',
- 'default' => '分销商',
- ],
- ]
- ];
- }
- }
|