| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629 |
- <?php
- namespace addons\Store\backend\controllers;
- use addons\Agent\common\models\AgentLevel;
- use addons\Boss\common\models\AddonsBossLevel;
- use addons\Distribution\common\models\DistributionLevel;
- use addons\DoubleCopy\common\models\DoubleCopyLevel;
- use addons\Store\common\enums\StoreEnum;
- use addons\Store\common\models\Store;
- use addons\Store\common\models\StoreCate;
- use addons\Store\common\models\StoreGoods;
- use addons\Store\common\models\StoreScoreStoreApply;
- use addons\Store\common\services\MerchantReduceProfitService;
- use addons\Store\common\sms\SmsConfig;
- use addons\Store\common\sms\PayRemindMessage;
- use addons\Store\common\sms\ShopExpireMessage;
- use addons\Store\common\models\StoreGoodsExtra;
- use addons\Store\common\models\StoreSettings;
- use addons\Store\common\models\StoreServiceRatioLog;
- use common\enums\RabbitMqEnum;
- use common\enums\AddonsEnum;
- use common\enums\ShippingTypeEnum;
- use common\enums\StatusEnum;
- use common\globals\GlobalInvoke;
- use common\helpers\wechat\WechatTemplate;
- use common\models\common\MallSetting;
- use common\models\goods\Goods;
- use common\models\mall\MallAddons;
- use common\models\user\UserLevel;
- use common\enums\WithdrawWayEnum;
- use common\helpers\sms\Sms;
- use common\models\mall\MallHost;
- use Overtrue\EasySms\EasySms;
- use function GuzzleHttp\json_encode;
- class StoreSettingController extends BaseController
- {
- public function actionIndex()
- {
- if (!\Yii::$app->request->isAjax) {
- return $this->render('/setting/index');
- }
- $is_install_distribution = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_DISTRIBUTION);
- $is_install_agent = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_AGENT);
- $is_install_boss = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_BOSS);
- $is_install_area = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_AREA);
- $is_install_double_copy = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_DOUBLE_COPY);
- $is_install_rebate = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_REBATE);
- if (\Yii::$app->request->isGet) {
- $web_url = \Yii::$app->services->setting->mall->get($this->mall_id, 'basic.web_url');
- if (empty($web_url)) {
- $h5_domain = 'https://h5.qijianshirjcs.com/';
- $mall_sign = '';
- } else {
- $url_info = explode('?', $web_url);
- $h5_domain = $url_info[0];
- $mall_sign = substr($url_info[1], mb_strlen('sign='));
- }
- $basic = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'basic');
- $cashier = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'cashier');
- $enter = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'enter');
- $mode = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'mode');
- $decoration = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'decoration');
- $goodsStore = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'goodsStore');
- $finance = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'finance');
- $payment = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'payment');
- $tips = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'tips');
- $advertising = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'advertising');
- $scoreGive = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'scoreGive');
- $rating_setting = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'rating_setting');
- $sms_setting = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'sms_setting');
- if (!empty($enter['goods_ids'])) {
- $goods_ids = json_decode($enter['goods_ids'], true);
- $goods = Goods::find()
- ->select('id,goods_name,cover_pic')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'id' => $goods_ids])
- ->asArray()
- ->all();
- } else {
- $goods_ids = $goods = [];
- }
- if (empty($enter)) {
- $enter = null;
- } else {
- $enter['goods_ids'] = $goods_ids;
- $enter['goods_list'] = $goods;
- $enter['template_store'] = empty($enter['template_store']) ? '' : json_decode($enter['template_store'], true);
- }
- if (empty($basic)) {
- $basic = [
- 'is_distribution_enable' => $is_install_distribution,
- 'is_agent_enable' => $is_install_agent,
- 'is_boss_enable' => $is_install_boss,
- 'is_area_enable' => $is_install_area,
- 'is_basic_null' => true,
- 'is_double_copy_enable' => $is_install_double_copy,
- 'is_rebate_enable' => $is_install_rebate,
- ];
- } else {
- $basic['is_distribution_enable'] = $is_install_distribution;
- $basic['is_agent_enable'] = $is_install_agent;
- $basic['is_boss_enable'] = $is_install_boss;
- $basic['is_area_enable'] = $is_install_area;
- $basic['is_double_copy_enable'] = $is_install_double_copy;
- $basic['is_rebate_enable'] = $is_install_rebate;
- }
- if(empty($basic['service_fee_settle_type'])) $basic['service_fee_settle_type'] = 1;
- if(empty($basic['localtion_limit'])) $basic['localtion_limit'] = 10;
- if(empty($basic['double_copy_status'])) $basic['double_copy_status'] = 0;
- if(empty($basic['store_distribution_status'])) $basic['store_distribution_status'] = 0;
- if(empty($basic['store_agent_status'])) $basic['store_agent_status'] = 0;
- if(empty($basic['store_area_status'])) $basic['store_area_status'] = 0;
- if(empty($basic['store_boss_status'])) $basic['store_boss_status'] = 0;
- if(empty($basic['store_rebate_status'])) $basic['store_rebate_status'] = 0;
- if(empty($basic['store_distribution_fee_type'])) $basic['store_distribution_fee_type'] = 1;
- if(empty($basic['store_area_fee_type'])) $basic['store_area_fee_type'] = 1;
- if(empty($basic['service_fee_type'])) $basic['service_fee_type'] = 0;
- if(empty($basic['max_platform_ratio'])) $basic['max_platform_ratio'] = null;
- if(empty($basic['min_platform_ratio'])) $basic['min_platform_ratio'] = null;
- if(empty($scoreGive['score_give_setting'])) {
- $scoreGive['score_give_setting'] = [
- 'is_open'=>0,
- 'bear'=>0,
- 'condition'=>1,
- 'give_type'=>1,
- 'give_num'=>0,
- 'settlement'=>0
- ];
- }else{
- $scoreGive['score_give_setting'] = json_decode($scoreGive['score_give_setting'],true);
- }
- if(!isset($scoreGive['score_give_is_store_alone'])){
- $scoreGive['score_give_is_store_alone'] = 0;
- }
- $scoreGive['store_limit_type'] = $scoreGive['store_limit_type'] ?? 0;
- $scoreGive['store_limit_stores'] = isset($scoreGive['store_limit_stores']) ? json_decode($scoreGive['store_limit_stores'], true) : [];
- $scoreGive['store_limit_protocol'] = $scoreGive['store_limit_protocol'] ?? '';
- if(empty($advertising)) {
- $advertising= ['is_open'=>0,'type'=>1, 'pic'=>'', 'url'=>''];
- }else{
- if(!isset($advertising['type'])) $advertising['type']= 1;
- }
- if(empty($rating_setting)) {
- $rating_setting= ['total_score'=>1,'environment_score'=>1, 'service_score'=>1, 'staff_score'=>1];
- }
- if (empty($sms_setting)) {
- $sms_setting = [
- 'is_pay_remind' => 0,
- 'pay_template_id' => '',
- 'pay_template_variable' => '',
- 'is_alert_expire' => 0,
- 'expire_day' => '',
- 'expire_template_id' => '',
- 'expire_template_variable' => ''
- ];
- }
- /* cashier */
- /* ---------- 用户权重相关配置处理 start ------ */
- $member_levels = UserLevel::find()
- ->select('level,name as level_name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- if (empty($member_levels)) {
- $member_levels = [
- // ['level' => 0, 'level_name' => '默认权重'],
- ];
- }
- if (!empty($cashier['members'])) {
- $setting_members = json_decode($cashier['members'], true);
- $mem_levels = array_column($setting_members, 'level');
- $mem_level_discount_map = array_column($setting_members, 'discount', 'level');
- } else {
- $mem_levels = [];
- $mem_level_discount_map = [];
- }
- foreach ($member_levels as &$mlevel) {
- if (!in_array($mlevel['level'], $mem_levels)) {
- $mlevel['discount'] = 0;
- } else {
- $mlevel['discount'] = floatval($mem_level_discount_map[$mlevel['level']] ?? 0);
- }
- }
- //获取服务费比例
- $platform_basic = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'basic');
- $cashier['platform_service_fee_setting'] = [
- 'max_platform_ratio' => $platform_basic['max_platform_ratio'],
- 'min_platform_ratio' => $platform_basic['min_platform_ratio']
- ];
- // dd($member_levels);
- /* ---------- 用户权重相关配置处理 end ------ */
- $currency_arr = ['commission' => '佣金', 'score' => '积分'];
- $mode['distribution_currency'] = $currency_arr;
- $currency = array_keys($currency_arr);
- // $addons_currency_arr = GlobalInvoke::exec(GlobalInvoke::INVOKE_COMMISSION_TYPE, $this->mall_id, ['mall_id' => $this->mall_id]);
- $addons_currency_arr = [];
- $addons_currency = [];
- $all_addons_currency = [];
- foreach ($addons_currency_arr as $v) {
- $mode['distribution_currency'] = array_merge($mode['distribution_currency'], array_column($v, 'label', 'name'));
- $temp_currency = array_column($v, 'name');
- $currency = array_merge($currency, $temp_currency);
- $addons_currency = array_merge($addons_currency, $temp_currency);
- $all_addons_currency = array_merge($all_addons_currency, array_column($v, 'label', 'name'));
- }
- /* ---------- 分销权重相关配置处理 start ------ */
- $level = \Yii::$app->services->setting->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_DISTRIBUTION, 'basic.level');
- if (empty($level)) $level = 0;
- $distribution_levels = [];
- if (!$is_install_distribution) {
- $is_distribution_enable = 0;
- } else {
- $is_distribution_enable = 1;
- $distribution_levels = DistributionLevel::find()
- ->select('level,name as level_name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- $init_data = ['level' => 0, 'level_name' => '默认权重'];
- if (empty($distribution_levels)) {
- $distribution_levels = [$init_data];
- } else {
- array_unshift($distribution_levels, $init_data);
- }
- }
- /* ---------- 分销权重相关配置处理 end ------ */
- /* ---------- 经销权重相关配置处理 start ------ */
- $cashier_agent_currency = ['settings' => '佣金'];
- $cashier['cashier_agent_currencys'] = array_merge($cashier_agent_currency, $all_addons_currency);
- $cashier_agent_currency_arr = array_keys($cashier['cashier_agent_currencys']);
- $agent_enable = $this->getCashierEnable(['settings' => ''], $addons_currency, $cashier, 'agent');
- $cashier = array_merge($cashier, $agent_enable['cashier']);
- $cashier['agent_enable_keys'] = $agent_enable['enable_keys'] ?? '';
- // 保存数据是额外验证的字段
- $cashier['validate_fields'] = array_merge($agent_enable['keys'], $agent_enable['ratio']);
- if (!$is_install_agent) {
- $agent_setting_keys = [];
- foreach ($cashier_agent_currency_arr as $agent_currency) {
- $agent_currency_key = 'agent_' . $agent_currency;
- $agent_setting_keys[] = $agent_currency_key;
- $cashier[$agent_currency_key] = [
- 'team_rewards' => [],
- 'equal_rewards' => [],
- 'over_rewards' => [],
- ];
- }
- $cashier['validate_fields'] = array_merge($cashier['validate_fields'], $agent_setting_keys);
- // $agent_settings = [
- // 'team_rewards' => [
- // // ['level' => 0, 'level_name' => '默认权重', 'commission_rate' => 0],
- // ],
- // 'equal_rewards' => [
- // // ['level' => 0, 'level_name' => '默认权重', 'commission_rate' => 0],
- // ],
- // 'over_rewards' => [
- // // ['level' => 0, 'level_name' => '默认权重', 'commission_rate' => 0],
- // ],
- // ];
- $is_agent_enable = 0;
- } else {
- $is_agent_enable = 1;
- $agent_levels = AgentLevel::find()
- ->select('level,name as level_name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- if (empty($agent_levels)) {
- $agent_levels = [
- // ['level' => 0, 'level_name' => '默认权重'],
- ];
- }
- $agent_data = $this->getCashierAgentData($agent_levels, $cashier_agent_currency_arr, $cashier);
- $cashier = array_merge($cashier, $agent_data['data']);
- $cashier['validate_fields'] = array_merge($cashier['validate_fields'], $agent_data['currency_keys']);
- // if (!empty($cashier['agent_settings'])) {
- // $agent_settings = json_decode($cashier['agent_settings'], true);
- // } else {
- // $agent_settings = [
- // 'team_rewards' => [
- // // ['level' => 0, 'level_name' => '默认权重', 'commission_rate' => 0],
- // ],
- // 'equal_rewards' => [
- // // ['level' => 0, 'level_name' => '默认权重', 'commission_rate' => 0],
- // ],
- // 'over_rewards' => [
- // // ['level' => 0, 'level_name' => '默认权重', 'commission_rate' => 0],
- // ],
- // ];
- // }
- // foreach ($agent_settings as $reward_name => $setting) {
- // foreach ($setting as $val) {
- // $agent_settings[$reward_name][$val['level']] = $val;
- // }
- // }
- // $ag_levels = array_column($agent_settings['team_rewards'], 'level');
- // $agent_level_settings = [];
- // foreach ($agent_levels as $alevel) {
- // if (!in_array($alevel['level'], $ag_levels)) {
- // $arr = $alevel;
- // $arr['commission_rate'] = 0;
- // $agent_level_settings['team_rewards'][] = $arr;
- // $agent_level_settings['equal_rewards'][] = $arr;
- // $agent_level_settings['over_rewards'][] = $arr;
- // } else {
- // $arr = [
- // 'level' => $alevel['level'],
- // 'level_name' => $alevel['level_name'],
- // 'commission_rate' => $agent_settings['team_rewards'][$alevel['level']]['commission_rate'] ?? 0,
- // ];
- // $agent_level_settings['team_rewards'][] = $arr;
- // $arr['commission_rate'] = $agent_settings['equal_rewards'][$alevel['level']]['commission_rate'] ?? 0;
- // $agent_level_settings['equal_rewards'][] = $arr;
- // $arr['commission_rate'] = $agent_settings['over_rewards'][$alevel['level']]['commission_rate'] ?? 0;
- // $agent_level_settings['over_rewards'][] = $arr;
- // }
- // }
- // $agent_settings = $agent_level_settings;
- /* ---------- 经销权重相关配置处理 end ------ */
- }
- if (empty($cashier)) {
- $cashier = [
- 'service_fee_ratio' => 0,
- 'member_status' => 0,
- 'is_distribution' => 0,
- 'is_agent' => 0,
- ];
- }
- $cashier['deepNames'] = [];
- if ($level > 0) $cashier['deepNames'][] = '一级';
- if ($level > 1) $cashier['deepNames'][] = '二级';
- if ($level > 2) $cashier['deepNames'][] = '三级';
- $cashier['members'] = $member_levels;
- $cashier_distribution_currencys = ['settings' => '佣金', 'settings_score' => '积分'];
- $cashier_distribution_currencys = array_merge($cashier_distribution_currencys, $all_addons_currency);
- $distribution_settings = $this->cashierDistributionData($distribution_levels, $cashier, array_keys($cashier_distribution_currencys));
- $cashier = array_merge($cashier, $distribution_settings['response']);
- $cashier['validate_fields'] = array_merge($cashier['validate_fields'], $distribution_settings['distribution_currency_key']);
- $cashier['is_distribution_enable'] = $is_distribution_enable;
- // $cashier['agent_settings'] = $agent_settings;
- $cashier['is_agent_enable'] = $is_agent_enable;
- // 分销收银配置是否开启的开关
- $distribution_enable_arr = ['settings' => '', 'settings_score' => 'score'];
- $distribution_enable = $this->getCashierEnable($distribution_enable_arr, $addons_currency, $cashier, 'distribution');
- $cashier = array_merge($cashier, $distribution_enable['cashier']);
- $distribution_enable_keys = $distribution_enable['enable_keys'] ?? '';
- $cashier['distribution_enable_keys'] = $distribution_enable_keys;
- $cashier['validate_fields'] = array_merge($cashier['validate_fields'], $distribution_enable['keys'], $distribution_enable['ratio']);
- $cashier['cashier_distribution_currencys'] = $cashier_distribution_currencys;
- /* 模式相关设置 */
- /* 分销模式设置 ---- start ------ */
- $mode['is_distribution_enable'] = $is_distribution_enable;
- if ($is_install_distribution) {
- $mode['Distribution'] = $this->getAddonsData($mode[AddonsEnum::ADDONS_NAME_DISTRIBUTION] ?? '', $distribution_levels, $currency, AddonsEnum::ADDONS_NAME_DISTRIBUTION);
- } else {
- $mode['Distribution'] = null;
- }
- /* 分销模式设置 ---- end ------ */
- /* 经销模式设置 ---- start ------ */
- $mode['is_agent_enable'] = $is_agent_enable;
- $mode['agent_currency'] = $mode['distribution_currency'];
- if ($is_install_agent) {
- $mode['Agent'] = $this->getAddonsData($mode[AddonsEnum::ADDONS_NAME_AGENT] ?? '', $agent_levels, $currency, AddonsEnum::ADDONS_NAME_AGENT);
- } else {
- $mode['Agent'] = null;
- }
- /* 经销模式设置 ---- end ------ */
- /* 股东分红模式设置 ---- start ------ */
- if ($is_install_boss) {
- $cashier['is_boss_enable'] = 1;
- $levels = AddonsBossLevel::find()
- ->select('level,name as level_name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- $cashier_boss_settings=[];
- if(isset($cashier['boss_settings'])){
- $cashier['boss_settings']=json_decode($cashier['boss_settings'],true);
- $cashier_boss_settings=isset($cashier['boss_settings']['rewards'])?$cashier['boss_settings']['rewards']:[];
- }
- $cashier['boss_settings']['rewards']=$this->getBossSetting($levels,$cashier_boss_settings);
- $cashier['boss_settings']['is_boss']=isset($cashier['boss_settings']['is_boss'])?$cashier['boss_settings']['is_boss']:0;
- $mode_boss_settings=[];
- if(isset($mode['boss_settings'])){
- $mode['boss_settings']=json_decode($mode['boss_settings'],true);
- $mode_boss_settings=isset($mode['boss_settings']['rewards'])?$mode['boss_settings']['rewards']:[];
- }
- $mode['boss_settings']['rewards']=$this->getBossSetting($levels,$mode_boss_settings);
- if(!empty($mode['boss_settings']['rewards'])){
- array_multisort(array_column($mode['boss_settings']['rewards'], 'level'), SORT_ASC, $mode['boss_settings']['rewards']);
- }
- $mode['boss_settings']['is_boss']=isset($mode['boss_settings']['is_boss'])?$mode['boss_settings']['is_boss']:0;
- $mode['is_boss_enable'] = 1;
- // $bs_details = [];
- // if (!empty($mode['Boss'])) {
- // $mode_boss_settings = json_decode($mode['Boss'], true);
- // if (!empty($mode_boss_settings['detail'])) {
- // foreach ($mode_boss_settings['detail'] as $detail) {
- // $bs_details[$detail['level']] = $detail;
- // }
- // }
- // }
- // $bs_level_settings = [];
- // foreach ($boss_levels as $blevel) {
- // if (empty($bs_details[$blevel['level']])) {
- // $arr = [
- // 'level' => $blevel['level'],
- // 'level_name' => $blevel['level_name'],
- // 'prize' => 0,
- // 'extra_prize' => 0,
- // ];
- // $bs_level_settings[] = $arr;
- // } else {
- // $bs_details[$blevel['level']]['level_name'] = $blevel['level_name'];
- // $bs_level_settings[] = $bs_details[$blevel['level']];
- // }
- // }
- // if (!empty($bs_level_settings)) {
- // $mode_boss_settings['detail'] = $bs_level_settings;
- // }
- // $mode['Boss'] = $mode_boss_settings;
- } else {
- $mode['is_boss_enable'] = 0;
- // $mode['Boss'] = null;
- }
- $boss_key=['boss_settings'];
- $cashier['validate_fields'] = array_merge($cashier['validate_fields'],$boss_key);
- /* 股东分红模式设置 ---- end ------ */
- /* 区域分红模式设置 ---- start ------ */
- $area_currency_arr = ['detail' => '佣金', 'detail_score' => '积分'];
- $area_currency_list = array_merge($area_currency_arr, $all_addons_currency);
- $mode['area_currency'] = $area_currency_list;
- $cashier['area_currency'] = $area_currency_list;
- $area_currency = array_keys($area_currency_arr);
- $area_currency = array_merge($area_currency, $addons_currency);
- if ($is_install_area) {
- $mode['is_area_enable'] = 1;
- $area_levels = [
- 6 => ['level' => 6, 'level_name' => '大区代'],
- 1 => ['level' => 1, 'level_name' => '省代'],
- 2 => ['level' => 2, 'level_name' => '市代'],
- 3 => ['level' => 3, 'level_name' => '区代'],
- 4 => ['level' => 4, 'level_name' => '镇代'],
- 5 => ['level' => 5, 'level_name' => '小区代']
- ];
- $mode['Area'] = $this->getAddonsData($mode[AddonsEnum::ADDONS_NAME_AREA] ?? '', $area_levels, $area_currency, AddonsEnum::ADDONS_NAME_AREA, 0, ['remaining_ratio']);
- } else {
- $mode['is_area_enable'] = 0;
- $mode['Area'] = null;
- }
- /* 收银台区域分红模式设置 ---- start ------ */
- if ($is_install_area) {
- $area_levels = [
- 6 => ['level' => 6, 'level_name' => '大区代'],
- 1 => ['level' => 1, 'level_name' => '省代'],
- 2 => ['level' => 2, 'level_name' => '市代'],
- 3 => ['level' => 3, 'level_name' => '区代'],
- 4 => ['level' => 4, 'level_name' => '镇代'],
- 5 => ['level' => 5, 'level_name' => '小区代']
- ];
- // 获取配置信息
- $areaSystem = $this->getAddonsData(
- $cashier['AreaCashier'] ?? '',
- $area_levels,
- $area_currency,
- AddonsEnum::ADDONS_NAME_AREA,
- 0,
- ['remaining_ratio']
- );
- $cashier['is_area_enable_cashier'] = 1;
- $cashier['AreaCashier'] = $areaSystem;
- } else {
- $cashier['is_area_enable_cashier'] = 0;
- $cashier['AreaCashier'] = null;
- }
- /* 收银台区域分红模式设置 ---- end ------ */
- /* 股东分红模式设置 ---- end ------ */
- $double_copy_carshier_key = AddonsEnum::ADDONS_NAME_DOUBLE_COPY.'_Cashier';
- if ($is_install_double_copy) {
- $double_copy_levels = DoubleCopyLevel::find()
- ->select('level,name as level_name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- $mode[AddonsEnum::ADDONS_NAME_DOUBLE_COPY] = $this->getAddonsData($mode[AddonsEnum::ADDONS_NAME_DOUBLE_COPY] ?? '', $double_copy_levels, ['commission'], AddonsEnum::ADDONS_NAME_DOUBLE_COPY, 1, [], ['is_percent' => 0]);
- $mode[$double_copy_carshier_key] = $this->getAddonsData($mode[$double_copy_carshier_key] ?? '', $double_copy_levels, ['commission'], AddonsEnum::ADDONS_NAME_DOUBLE_COPY, 1, [], ['is_percent' => 0]);
- $cashier['is_double_copy_enable_cashier'] = 1;
- $cashier[$double_copy_carshier_key] = $this->getAddonsData($cashier[$double_copy_carshier_key] ?? '', $double_copy_levels, ['commission'], AddonsEnum::ADDONS_NAME_DOUBLE_COPY, 1, [], ['is_percent' => 0]);
- } else {
- $mode[AddonsEnum::ADDONS_NAME_DOUBLE_COPY] = null;
- $mode[$double_copy_carshier_key] = null;
- $cashier['is_double_copy_enable_cashier'] = 0;
- }
- if ($is_install_rebate) {
- $mode[AddonsEnum::ADDONS_NAME_REBATE] = $this->getRebateData($mode[AddonsEnum::ADDONS_NAME_REBATE] ?? '');
- } else {
- $mode[AddonsEnum::ADDONS_NAME_REBATE] = null;
- }
- // dd($mode);
- if(!isset( $cashier['member_status'])){
- $cashier['member_status'] = 0;
- }
- $goodsStore['is_limit_max_price'] = isset($goodsStore['is_limit_max_price'])&&$goodsStore['is_limit_max_price']=='true'?true:false;
- $H5Url = \Yii::$app->services->setting->platform->get('system.h5_url');
- $store_h5_login_url = $H5Url . '/#/plugins2/Store/admin/login?sign=' . $this->mall['mall_sign'];
- $store_setting['store_h5_login_url'] =$store_h5_login_url ;
- //收银台设置
- $cashier['collect_reward_info'] = json_decode($cashier['collect_reward_info'] ?? '', true) ?? [];
- $cashier['payment_reward_info'] = json_decode($cashier['payment_reward_info'] ?? '', true) ?? [];
- $cashier['collect_reward'] = array_column($cashier['collect_reward_info'],'type');
- $cashier['payment_reward'] = array_column($cashier['payment_reward_info'],'type');
- $payment_reward_info = [];
- $collect_reward_info = [];
- $scoreExpansionConfig = \Yii::$app->services->setting->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_SCORE_EXPANSION, 'basic');
- if(!empty($scoreExpansionConfig) && !empty($scoreExpansionConfig['frozen_status'])){
- $name = empty($scoreExpansionConfig['integral_name']) ? '激活积分' : '激活'.$scoreExpansionConfig['integral_name'];
- $payment_reward_info[] = [
- 'name'=> $name,
- 'type' => 'payment_parent_reward_score',
- 'value' => '',
- ];
- $payment_reward_info[] = [
- 'name'=> $name,
- 'type' => 'payment_reward_score',
- 'value' => '',
- ];
- $collect_reward_info[] = [
- 'name'=> $name,
- 'type' => 'collect_reward_score',
- 'value' => '',
- ];
- $collect_reward_info[] = [
- 'name'=>$name,
- 'type' => 'collect_parent_reward_score',
- 'value' => '',
- ];
- }
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_CONTRIBUTION_CURRENCY)) {
- $collect_reward_info[] = [
- 'name'=> '贡献值',
- 'type' => 'collect_reward_contribution',
- 'value' => '',
- ];
- }
- if(!empty($collect_reward_info) && !empty($cashier['collect_reward_info'])){
- foreach($collect_reward_info as &$info){
- foreach($cashier['collect_reward_info'] as $item){
- if($item['type'] == $info['type']){
- $info['value'] = $item['value'];
- }
- }
- }
- }
- if(!empty($payment_reward_info) && !empty($cashier['payment_reward_info'])){
- foreach($payment_reward_info as &$info){
- foreach($cashier['payment_reward_info'] as $item){
- if($item['type'] == $info['type']){
- $info['value'] = $item['value'];
- }
- }
- }
- }
- //收款方
- $cashier['collect_reward_info'] = $collect_reward_info;
- $cashier['preferential_undertaking'] = $cashier['preferential_undertaking']??'1';
- //付款方
- $cashier['payment_reward_info'] = $payment_reward_info;
- //收款码额度
- $cashier['cashier_amount_info'] = json_decode($cashier['cashier_amount_info'] ?? '',true) ?? [];
- $cashier['cashier_amount'] = array_column($cashier['cashier_amount_info'],'type');
- $cashier_amount_info = [
- ['type' => 'cashier_amount','value' => 0],
- ['type' => 'cashier_amount_month','value' => 0]
- ];
- if(!empty($cashier_amount_info) && !empty($cashier['cashier_amount_info'])){
- foreach($cashier_amount_info as &$info){
- foreach($cashier['cashier_amount_info'] as $item){
- if($item['type'] == $info['type']){
- $info['value'] = $item['value'];
- }
- }
- }
- }
- $cashier['cashier_amount_info'] = $cashier_amount_info;
- $cashier['cashier_settle_type'] = $cashier['cashier_settle_type'] ?? 1;
- //货款设置
- $basic['payment_settle_info'] = json_decode($basic['payment_settle_info'],true) ?? [];
- $basic['payment_settle'] = array_column($basic['payment_settle_info'],'type');
- $payment_settle_info = [
- ['type' => 'settle_judge_yes','value' => 0],
- ['type' => 'settle_judge_no','value' => 0]
- ];
- if(!empty($payment_settle_info) && !empty($basic['payment_settle_info'])){
- foreach($payment_settle_info as &$info){
- foreach($basic['payment_settle_info'] as $item){
- if($item['type'] == $info['type']){
- $info['value'] = $item['value'];
- }
- }
- }
- }
- $basic['payment_settle_info'] = $payment_settle_info;
- //资产设置
- $default_withdraw_way = WithdrawWayEnum::getDefaultWithDrawWayMap(WithdrawWayEnum::WITHDRAW_TYPE_2);
- $extension_withdraw_way = GlobalInvoke::exec(GlobalInvoke::INVOKE_GET_WITHDRAW_EXTENSION_WAY,$this->mall_id);
- $all_withdraw = array_merge($default_withdraw_way,$extension_withdraw_way);
- if (!empty($all_withdraw['alipay_tax'])) {
- $all_withdraw['alipay_tax'] = $all_withdraw['alipay_tax']['name'];
- }
- $finance['balance_withdraw_way'] = $all_withdraw;
- //提现条件
- if(!empty($finance['balance_cash_type'])){
- $finance['balance_cash_type'] = json_decode($finance['balance_cash_type'],true);
- }else{
- //默认银行卡/余额提现
- $finance['balance_cash_type'] = ['balance','bank'];
- }
- if(!isset($finance['balance_cash_service_fee'])){
- $balance_cash_service_fee = \Yii::$app->services->setting->mall->get($this->mall_id, 'withdraw_balance.balance_cash_service_fee');
- $finance['balance_cash_service_fee'] = $balance_cash_service_fee;
- }
- if(!isset($finance['balance_cash_service_fee_limit'])){
- $finance['balance_cash_service_fee_limit'] = 0;
- }
- //支付方式
- if(!isset($payment['payment_is_enable'])){
- $payment['payment_is_enable'] = 0;
- }
- if(!isset($payment['score_pay_setting'])){
- $payment['score_pay_setting'] = 0;
- }
- if(!isset($payment['score_pay'])){
- $payment['score_pay'] = 0;
- }
- if(!isset($payment['score_pay_password_status'])){
- $payment['score_pay_password_status'] = 0;
- }
- if(empty($payment['payment_type'])){
- $payment['payment_type'] = [];
- }else{
- $payment['payment_type'] = json_decode($payment['payment_type'],true);
- }
- if (empty($payment['pay_after_link'])) {
- $payment['pay_after_link'] = '';
- } else {
- $payment['pay_after_link'] = json_decode($payment['pay_after_link'], true);
- }
- $payment['payment_way'] = \Yii::$app->services->pay->getEnablePaymentType($this->mall_id);
- if(!isset($payment['score_open_type'])) $payment['score_open_type'] = 1;
- $goodsStore['express_title_arr'] = ($goodsStore['express_title_arr'] ?? '') ? json_decode($goodsStore['express_title_arr'] ?? '',true) : ShippingTypeEnum::getMap();
- $deduction_proportion = [['min'=>'','max'=>'','deduction_ratio'=>'']];
- if(empty($payment['score_deduction'])){
- $payment['score_deduction'] = [
- 'is_score_deduction' => 0,
- 'effective' => 1,
- 'bear' => 0,
- 'score_balance_ratio' => '',
- 'deduction_proportion' => $deduction_proportion,
- 'deduction_type' => 0,
- 'max_deduction_percent' => 0,
- 'store_limit_type' => 0,
- 'store_limit_stores' => [],
- 'store_limit_stores_deduction' => []
- ];
- }else{
- $payment['score_deduction'] = json_decode($payment['score_deduction'],true);
- if(empty($payment['score_deduction']['deduction_proportion'])){
- $payment['score_deduction']['deduction_proportion'] = $deduction_proportion;
- }
- $payment['score_deduction']['deduction_type'] = $payment['score_deduction']['deduction_type'] ?? 0;
- $payment['score_deduction']['max_deduction_percent'] = $payment['score_deduction']['max_deduction_percent'] ?? 0;
- $payment['score_deduction']['store_limit_type'] = $payment['score_deduction']['store_limit_type'] ?? 0;
- $payment['score_deduction']['store_limit_stores_deduction'] = $payment['score_deduction']['store_limit_stores_deduction'] ?? [];
- $payment['score_deduction']['store_limit_stores'] = array_keys($payment['score_deduction']['store_limit_stores_deduction']);
- }
- if(!isset($decoration['default_store_cate_style'])){
- $decoration['default_store_cate_style'] = 1;
- }
- $settings = [
- 'basic' => $basic,
- 'cashier' => $cashier,
- 'enter' => $enter,
- 'mode' => $mode,
- 'decoration' => $decoration,
- 'goodsStore' => $goodsStore,
- 'store_setting' => $store_setting,
- 'finance' => $finance,
- 'payment' => $payment,
- 'tips' => empty($tips) ? ['link_tips' => '', 'bank_account_tips' => '',] : $tips,
- 'advertising' => $advertising,
- 'scoreGive' => $scoreGive,
- 'rating_setting' => $rating_setting,
- 'sms_setting' => $sms_setting,
- ];
- $group = \Yii::$app->request->get('group');
- if (!empty($group)) {
- $settings = $settings[$group] ?? [];
- }
- $settings['h5_domain'] = MallHost::getHost($this->mall_id, 'h5_url');
- $settings['mall_sign'] = $this->mall['mall_sign'];
- $settings['level'] = $level;
- $settings['basic']['o2o_url'] = 'plugins2/Store/store/storeindex';
- $notice_wechat_config = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'notice');
- $notice_wechat_template_message_list = StoreEnum::getWechatTemplateMap();
- $notice_wechat = empty($notice_wechat_config['notice_wechat']) ? [] : json_decode($notice_wechat_config['notice_wechat'],true);
- $notice_wechat_template_message_value = $notice_wechat['template_message'] ?? [];
- foreach ($notice_wechat_template_message_list as $key=>$template_name){
- if(!isset($notice_wechat_template_message_value[$key])){
- $notice_wechat_template_message_value[$key] = ['tem_key'=>'', 'name'=>$template_name, 'tempid'=>'',];
- }
- }
- $settings['notice_wechat']['is_logging'] = $notice_wechat['is_logging'] ?? 1;
- $settings['notice_wechat']['template_message'] = $notice_wechat_template_message_value;
- return $this->success('success', $settings);
- } else {
- $post = \Yii::$app->request->post();
- $group = $post['group'] ?? '';
- unset($post['_csrf'], $post['group']);
- if (empty($group)) {
- return $this->error('参数错误');
- }
- $validate_fields = [];
- if ($group == 'cashier') {
- $validate_fields = $post[$group]['validate_fields'];
- }
- $rules = [
- 'basic' => [
- [['o2o_url', 'goods_auth', 'service_fee', 'settle_type', 'platform_ratio', 'risk_management', 'risk_management_ratio', 'settle_scene', 'store_distribution_status', 'store_agent_status', 'store_area_status', 'store_boss_status', 'double_copy_status','store_rebate_status','service_fee_settle_type'], 'required'],
- [['o2o_url','platform_address','suona_appSecret','suona_appId','suona_host'], 'string', 'max' => 255],
- [['goods_auth', 'settle_type', 'risk_management', 'settle_scene', 'store_distribution_status', 'store_agent_status', 'store_area_status', 'store_boss_status','watch_times','recommend_nums','is_show_location_store', 'double_copy_status','store_rebate_status','is_enable_dollars_symbol', 'is_location_limit', 'service_fee_type', 'store_distribution_fee_type', 'store_area_fee_type','service_fee_settle_type'], 'integer'],
- [['service_fee', 'platform_ratio', 'risk_management_ratio', 'min_platform_ratio','max_platform_ratio'], 'number', 'min' => 0, 'max' => 100, 'message' => '比例取值在 0 ~ 100 之间'],
- [['localtion_limit'], 'number'],
- [['payment_settle_info','payment_settle','score_give_setting','total_score','speciality','service_attitude','timeliness'],'safe'],
- [['dollars_symbol'],'string'],
- ],
- 'cashier' => [
- //distribution_settings distribution_settings_score no required
- [['service_fee_ratio', 'member_status', 'is_distribution', 'is_agent','preferential_undertaking'], 'required'],
- [['member_status', 'is_distribution', 'is_distribution_score', 'is_agent', 'cashier_settle_type'], 'integer'],
- [array_merge(['members', 'agent_settings'], $validate_fields), 'safe'],
- [['service_fee_ratio'], 'number', 'min' => 0, 'max' => 100, 'message' => '比例取值在 0 ~ 100 之间'],
- [['collect_reward','payment_reward','collect_reward_info','payment_reward_info','cashier_amount','cashier_amount_info','cashier_bg_img','payment_settle_info','DoubleCopy_Cashier', 'AreaCashier'],'safe'],
- ],
- 'enter' => [
- [['is_enable', 'time_status', 'expired_days', 'store_audit', 'upload_license_image', 'mode'], 'required'],
- [['is_enable', 'time_status', 'expired_days', 'store_audit', 'upload_license_image', 'mode','store_auth', 'is_template', 'is_front_template'], 'integer'],
- [['recruit_title', 'recruit_content', 'recruit_btn_text', 'dow_center_agreement'], 'string'],
- ['goods_ids', 'safe'],
- [['buy_store_num', 'finish_order_num','template_store'], 'safe'],
- ],
- 'mode' => [
- [['is_enable_mode'], 'required'],
- ['is_enable_mode', 'integer'],
- [['Distribution', 'Agent', 'Boss', 'Area','boss_settings', 'DoubleCopy','Rebate'], 'safe']
- ],
- 'decoration' => [
- [['custom_goods_style','default_goods_style','custom_store_style','default_store_style','default_store_cate_style', 'store_category_switch'], 'integer'],
- [['near_shop_title'],'string']
- ],
- 'goodsStore' => [
- [['min_price','max_price','is_limit_max_price', 'is_hidden_goods_store'], 'safe'],
- [['express_title_arr'],'safe']
- ],
- 'store' => [
- [['store_h5_login_url'], 'safe'], [['service_fee_ratio', 'member_status', 'is_distribution', 'is_agent','preferential_undertaking'], 'required'],
- ],
- 'finance' => [
- ['freeze_is_enable', 'integer'],
- ['finance_name', 'string'],
- [['balance_cash_type','balance_cash_service_fee','balance_cash_service_fee_limit','balance_cash_service_fee_month','balance_cash_service_fee_diff','balance_cash_service_fee_month'],'safe'],
- ],
- 'payment' => [
- [['payment_is_enable','score_pay_setting','score_pay','score_pay_password_status','score_open_type'], 'integer'],
- [['store_limit_protocol'], 'string'],
- [['payment_type', 'pay_after_link','score_deduction'],'safe'],
- ],
- 'tips' => [
- [['bank_account_tips', 'link_tips'],'string'],
- ],
- 'advertising' => [
- [['is_open','type'],'integer'],
- [['pic', 'url'],'string'],
- ],
- 'rating_setting' => [
- [['total_score','environment_score','service_score','staff_score'],'integer'],
- ],
- 'scoreGive' => [
- [['score_give_setting', 'store_limit_stores'], 'safe'],
- [['score_give_is_store_alone', 'store_limit_type'], 'integer'],
- [['store_limit_protocol'], 'string']
- ],
- 'sms_setting' => [
- [['is_pay_remind', 'pay_template_id', 'pay_template_variable'], 'safe'],
- [['is_pay_remind', 'is_alert_expire', 'expire_day'], 'integer'],
- [['pay_template_id', 'pay_template_variable', 'expire_template_id', 'expire_template_variable'], 'string']
- ],
- 'notice' => [
- [['notice_wechat'], 'safe'],
- ]
- ];
- $res = \Yii::$app->services->validate->validate($post[$group], $rules[$group]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- if ('basic' == $group) {
- // if(isset($post['basic']['recommend_nums'])){
- // $store_goods= StoreGoods::find()
- // ->select("count(*) counts,store_id")
- // ->where(['mall_id'=>$this->mall_id,'status'=>StatusEnum::ENABLED,'is_recommend'=>1])
- // ->groupBy('store_id')->orderBy('counts desc')->asArray()->one();
- // if(!empty($store_goods['counts'])&&$post['basic']['recommend_nums']<$store_goods['counts']){
- // return $this->error('允许推荐商品数量不能低于'.$store_goods['counts']);
- // }
- // }
- $post[$group]['o2o_url'] = trim($post[$group]['o2o_url']);
- if (!empty($post[$group]['payment_settle'])) {
- foreach($post[$group]['payment_settle_info'] as $key => $item){
- if(!in_array($item['type'],$post[$group]['payment_settle'])){
- unset($post[$group]['payment_settle_info'][$key]);
- }
- }
- }else{
- $post[$group]['payment_settle_info'] = [];
- }
- unset($post[$group]['payment_settle']);
- if ($post[$group]['service_fee'] == 1 && $post[$group]['service_fee_type'] == 1) {
- if ($post[$group]['min_platform_ratio'] > $post[$group]['max_platform_ratio']) {
- return $this->error('服务费最高比例不能小于最低比例');
- }
- }
- } elseif ('enter' == $group) {
- if (empty($post[$group]['goods_ids'])) {
- $post[$group]['goods_ids'] = '';
- } else {
- $post[$group]['goods_ids'] = json_encode($post[$group]['goods_ids']);
- }
- if (empty($post[$group]['template_store'])) {
- $post[$group]['template_store'] = '';
- } else {
- $post[$group]['template_store'] = json_encode($post[$group]['template_store']);
- }
- }elseif ('goodsStore' == $group) {
- if($post['goodsStore']['is_limit_max_price']=='false'){
- if($post['goodsStore']['min_price']>$post['goodsStore']['max_price']){
- return $this->error('最低价格不能大于最高价格');
- }
- }
- }elseif ('cashier' == $group) {
- if (!empty($post[$group]['collect_reward'])) {
- foreach($post[$group]['collect_reward_info'] as $key => $item){
- if(in_array($item['type'],$post[$group]['collect_reward'])){
- unset($post[$group]['collect_reward_info'][$key]['name']);
- }else{
- unset($post[$group]['collect_reward_info'][$key]);
- }
- }
- }else{
- $post[$group]['collect_reward_info'] = [];
- }
- unset($post[$group]['collect_reward']);
- if (!empty($post[$group]['payment_reward'])) {
- foreach($post[$group]['payment_reward_info'] as $key => $item){
- if(in_array($item['type'],$post[$group]['payment_reward'])){
- unset($post[$group]['payment_reward_info'][$key]['name']);
- }else{
- unset($post[$group]['payment_reward_info'][$key]);
- }
- }
- }else{
- $post[$group]['payment_reward_info'] = [];
- }
- unset($post[$group]['payment_reward']);
- if (!empty($post[$group]['cashier_amount'])) {
- foreach($post[$group]['cashier_amount_info'] as $key => $item){
- if(!in_array($item['type'],$post[$group]['cashier_amount'])){
- unset($post[$group]['cashier_amount_info'][$key]);
- }
- }
- }else{
- $post[$group]['cashier_amount_info'] = [];
- }
- unset($post[$group]['cashier_amount']);
- $basic = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'basic');
- //需要收取服务费
- if (!empty($basic['service_fee']) && !empty($post[$group]['service_fee_ratio'])) {
- //收银台服务费是否在基础设置的服务费区间
- if ($post[$group]['service_fee_ratio'] > $basic['max_platform_ratio'] || $post[$group]['service_fee_ratio'] < $basic['min_platform_ratio']) {
- return $this->error('只能设置在平台服务费比例区间内的比例当前平台服务费比例:' . $basic['min_platform_ratio'] . '%~' . $basic['max_platform_ratio'] . '%');
- }
- }
- }elseif ('finance' == $group) {
- if (empty($post[$group]['balance_cash_type'])) {
- $post[$group]['balance_cash_type'] = '';
- } else {
- $post[$group]['balance_cash_type'] = json_encode($post[$group]['balance_cash_type']);
- }
- }elseif ('payment' == $group) {
- if (empty($post[$group]['payment_type'])) {
- $post[$group]['payment_type'] = '';
- } else {
- $post[$group]['payment_type'] = json_encode($post[$group]['payment_type']);
- }
- if (!empty($post[$group]['pay_after_link'])) {
- $post[$group]['pay_after_link'] = json_encode($post[$group]['pay_after_link']);
- }
- empty($post[$group]['score_deduction']['store_limit_stores_deduction']) && $post[$group]['score_deduction']['store_limit_stores_deduction'] = [];
- if(isset($post[$group]['score_deduction']['store_limit_stores'])) unset($post[$group]['score_deduction']['store_limit_stores']);
- }elseif ('tips' == $group) {
- }elseif ('scoreGive' == $group) {
- if(empty($post[$group]['score_give_setting']['give_num'])){
- $post[$group]['score_give_setting']['give_num'] = 0;
- }
- empty($post[$group]['store_limit_stores']) && $post[$group]['store_limit_stores'] = [];
- }elseif ('rating_setting' == $group) {
- if (empty($post[$group]['total_score']) && empty($post[$group]['environment_score']) && empty($post[$group]['service_score']) && empty($post[$group]['staff_score'])) {
- return $this->error('请设置评分设置');
- }
- } elseif ('sms_setting' == $group) {
- if ($post[$group]['is_pay_remind'] && (empty($post[$group]['pay_template_id'] || empty($post[$group]['pay_template_variable'])))) {
- return $this->error('请完善短信设置');
- }
- }
- \Yii::$app->services->setting->addons->set($this->mall_id, StoreEnum::ADDONS_NAME, $post);
- if ('basic' == $group && $post[$group]['service_fee_type']) {
- //收银设置服务费
- $cashier_service_fee_ratio = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'cashier.service_fee_ratio');
- if ($cashier_service_fee_ratio > $post[$group]['max_platform_ratio'] || $cashier_service_fee_ratio < $post[$group]['min_platform_ratio']) {
- \Yii::$app->services->setting->addons->set($this->mall_id, StoreEnum::ADDONS_NAME, ['cashier' => [
- 'service_fee_ratio' => $post[$group]['max_platform_ratio']
- ]]);
- }
- //服务费是区间的时候 要处理 O2O的服务费独立设置
- \Yii::$app->services->rabbitMq->push(RabbitMqEnum::EXCHANGE_TASK, RabbitMqEnum::TASK_QUEUE, [
- 'mall_id' => $this->mall_id,
- 'max_platform_ratio' => $post[$group]['max_platform_ratio'],
- 'min_platform_ratio' => $post[$group]['min_platform_ratio'],
- ], StoreGoodsExtra::class, 'updateServiceFeeSetting');
- \Yii::$app->services->rabbitMq->push(RabbitMqEnum::EXCHANGE_TASK, RabbitMqEnum::TASK_QUEUE, [
- 'mall_id' => $this->mall_id,
- 'max_platform_ratio' => $post[$group]['max_platform_ratio'],
- 'min_platform_ratio' => $post[$group]['min_platform_ratio'],
- ], StoreSettings::class, 'updateServiceFeeSetting');
- }
- return $this->success('保存成功');
- }
- }
- public function actionSendSms()
- {
- try {
- $post = \Yii::$app->request->post();
- // $params = \Yii::$app->request->post();
- // if (empty($params['mobile'])) return $this->error('请输入手机号码');
- $smsConfig = MallSetting::getConfByGroup($this->mall_id, 'notice_sms', true);
- switch ($smsConfig['platform']['value']) {
- case 'aliyun'://阿里云配置
- $mobile = $smsConfig['mobile']['value'];
- break;
- case 'qcloud'://阿里云配置
- $mobile = $smsConfig['qcloud_mobile']['value'];
- break;
- case 'submail'://阿里云配置
- $mobile = $smsConfig['submail_mobile']['value'];
- break;
- }
- if (!$mobile) {
- return $this->error('请完善平台设置-短信设置-手机号');
- }
- $SmsConfig = new Sms($this->mall_id);
- switch ($post['type']) {
- case 3:
- // $SmsConfig = new SmsConfig($this->mall_id);
- $easy_sms = $SmsConfig->easySms;
- $message = new PayRemindMessage($this->mall_id, 'order_123', '自提');
-
- break;
-
- case 4:
- // $SmsConfig = new Sms($this->mall_id);
- $easy_sms = $SmsConfig->easySms;
- $message = new ShopExpireMessage($this->mall_id, '6', '测试门店');
- break;
- }
- $easy_sms->send($mobile, $message);
- return $this->success('发送成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- public function getCashierEnable($init_enable_arr, $addons_currency, $cashier, $addon_key)
- {
- $addons_distribution_enable_arr = [];
- foreach ($addons_currency as $v) {
- $addons_distribution_enable_arr[$v] = $v;
- }
- $enable_keys = [];
- $keys = [];
- $ratio = [];
- $remaining_ratio = [];
- $loop_enble_arr = array_merge($init_enable_arr, $addons_distribution_enable_arr);
- foreach ($loop_enble_arr as $k => $item) {
- $ratio_index = $addon_key . '_' . $k . '_remaining_ratio';
- $ratio[] = $ratio_index;
- $remaining_ratio[$ratio_index] = $cashier[$ratio_index] ?? 0;
- if (empty($item)) {
- $keys[] = 'is_' . $addon_key;
- $enable_keys['is_' . $addon_key] = 0;
- } else {
- $keys[] = 'is_' . $addon_key . '_' . $item;
- $enable_keys['is_' . $addon_key . '_' . $item] = 0;
- }
- }
- foreach (array_merge($enable_keys, $remaining_ratio) as $k => $v) {
- if (!isset($cashier[$k])) {
- $cashier[$k] = $v;
- }
- }
- return compact('cashier', 'keys', 'ratio');
- }
- public function getCashierAgentData($agent_levels, $currencys, $cashier)
- {
- $data = [];
- $currency_keys = [];
- foreach ($currencys as $currency) {
- $currency_key = 'agent_' . $currency;
- $currency_keys[] = $currency_key;
- if (!empty($cashier[$currency_key])) {
- $currency_settings = json_decode($cashier[$currency_key], true);
- } else {
- $currency_settings = [
- 'team_rewards' => [],
- 'equal_rewards' => [],
- 'over_rewards' => [],
- ];
- }
- foreach ($currency_settings as $reward_name => $setting) {
- foreach ($setting as $val) {
- $currency_settings[$reward_name][$val['level']] = $val;
- }
- }
- $ag_levels = array_column($currency_settings['team_rewards'], 'level');
- $level_settings = [];
- foreach ($agent_levels as $alevel) {
- if (!in_array($alevel['level'], $ag_levels)) {
- $arr = $alevel;
- $arr['commission_rate'] = 0;
- $level_settings['team_rewards'][] = $arr;
- $level_settings['equal_rewards'][] = $arr;
- $level_settings['over_rewards'][] = $arr;
- } else {
- $arr = [
- 'level' => $alevel['level'],
- 'level_name' => $alevel['level_name'],
- 'commission_rate' => $currency_settings['team_rewards'][$alevel['level']]['commission_rate'] ?? 0,
- ];
- $level_settings['team_rewards'][] = $arr;
- $arr['commission_rate'] = $currency_settings['equal_rewards'][$alevel['level']]['commission_rate'] ?? 0;
- $level_settings['equal_rewards'][] = $arr;
- $arr['commission_rate'] = $currency_settings['over_rewards'][$alevel['level']]['commission_rate'] ?? 0;
- $level_settings['over_rewards'][] = $arr;
- }
- }
- $data[$currency_key] = $level_settings;
- }
- return compact('data', 'currency_keys');
- }
- /**
- * @Description: 处理插件模式数据
- * @Author: qi
- * @DateTime 2022-11-10 09:59:45
- * @param string $init_data
- * @param array $level_data
- * @param array $currencys
- * @param string $addons_name
- * @param integer $level
- * @param array $append_fields
- * @param array $ext
- * @return array
- */
- protected function getAddonsData($init_data, $level_data, $currencys, $addons_name, $level = 1, $append_fields = [], $ext = [])
- {
- $settings = [];
- $container_arr = [];
- if (!empty($init_data)) {
- // 已存储的数据
- $settings = json_decode($init_data, true);
- foreach ($currencys as $currency) {
- if (!isset($settings[$currency])) continue;
- $currency_detail = $level == 1 ? $settings[$currency]['detail'] : $settings[$currency];
- if(!empty($currency_detail)){
- foreach ($currency_detail as $detail) {
- // 币种对应的权重数据
- if (!isset($detail['level'])) {
- continue;
- }
- $container_arr[$currency . '_' . $detail['level']] = $detail;
- }
- }
- }
- }else{
- foreach ($currencys as $currency) {
- $settings[$currency]['is_enable'] = 0;
- if(!empty($ext)){
- foreach($ext as $key => $val){
- $settings[$currency][$key] = $val;
- }
- }
- }
- }
- $method_name = 'get' . $addons_name . 'InitData';
- foreach ($currencys as $item) {
- $level_settings = [];
- // 不存在该权重数据就初始化,存在该权重则更新权重名称
- foreach ($level_data as $dlevel) {
- if (!isset($container_arr[$item . '_' . $dlevel['level']])) {
- $arr = [
- 'level' => $dlevel['level'],
- 'level_name' => $dlevel['level_name'],
- ];
- $arr = array_merge($arr, $this->$method_name());
- $level_settings[] = $arr;
- } else {
- // 更新对应权重名称
- $container_arr[$item . '_' . $dlevel['level']]['level_name'] = $dlevel['level_name'];
- $level_settings[] = $container_arr[$item . '_' . $dlevel['level']];
- }
- }
- if (!empty($level_settings)) {
- if ($level == 1) {
- $settings[$item]['detail'] = $level_settings;
- } else {
- $settings[$item] = $level_settings;
- }
- }
- }
- foreach ($currencys as $v) {
- foreach ($append_fields as $field) {
- if (isset($settings[$v . '_' . $field])) continue;
- $settings[$v . '_' . $field] = 0;
- }
- }
- unset($container_arr);
- return $settings;
- }
- /**
- * 获取推三返一数据
- * 作者:zengfanhua
- * 创建时间:2024/07/14 02:11:21
- */
- protected function getRebateData($init_data)
- {
- $settings = [];
- if (!empty($init_data)) {
- // 已存储的数据
- $settings = json_decode($init_data, true);
- return $settings;
- }
- else
- {
- $detail=$this->getRebateInitData();
- return ['is_enable'=>0,'detail'=>$detail];
- }
- }
- protected function getDistributionInitData()
- {
- return [
- 'first_prize' => 0,
- 'second_prize' => 0,
- 'third_prize' => 0,
- 'is_percent' => 0,
- 'remaining_ratio' => 0
- ];
- }
- protected function getAgentInitData()
- {
- return [
- 'agent_team_prize' => 0,
- 'agent_equal_prize' => 0,
- 'agent_over_prize' => 0,
- 'agent_extra_prize' => 0,
- 'remaining_ratio' => 0,
- 'is_percent_over' => 0,
- 'is_percent_equal' => 0,
- 'is_percent_team' => 0,
- 'is_percent_extra' => 0
- ];
- }
- protected function getAreaInitData()
- {
- return [
- 'prize' => 0,
- 'equal_prize' => 0,
- ];
- }
- protected function getDoubleCopyInitData()
- {
- return [
- 'first_prize' => 0,
- 'indirect_prize' => 0,
- 'second_prize' => 0,
- 'equal_prize' => 0,
- 'allowance_price' => 0,
- ];
- }
- protected function getRebateInitData()
- {
- return [
- 'initiate_type' => 0,
- 'initiate_level' => [],
- 'consume_type' => 0,
- 'consume_level' => [],
- 'reward_type' => 1,
- 'reward_info' => [],
- 'is_repeat' => 0,
- 'join_type' => 0,
- 'repeat_setting' => 0,
- 'agent_limit_num' => 0,
- ];
- }
- protected function cashierDistributionData($distribution_levels, $cashier, $currencys = [])
- {
- // $data = [];
- // $level_arr = [];
- // switch ($type) {
- // case 'score':
- // if (!empty($cashier['distribution_settings_score'])) {
- // $distribution_settings_score = json_decode($cashier['distribution_settings_score'], true);
- // $level_arr = array_column($distribution_settings_score, 'level');
- // $data = $distribution_settings_score;
- // }
- // break;
- // case 'commission':
- // if (!empty($cashier['distribution_settings'])) {
- // $distribution_settings = json_decode($cashier['distribution_settings'], true);
- // $level_arr = array_column($distribution_settings, 'level');
- // $data = $distribution_settings;
- // }
- // break;
- // }
- // foreach ($distribution_levels as $val) {
- // if (!in_array($val['level'], $level_arr)) {
- // $data[] = [
- // 'level' => $val['level'],
- // 'level_name' => $val['level_name'],
- // 'commission_rate' => [0, 0]
- // ];
- // }
- // if (isset($data[$val['level']])) {
- // $data[$val['level']]['level_name'] = $val['level_name'];
- // }
- // }
- // return $data;
- $response = [];
- $distribution_currency_key = [];
- $now_level_arr = (array)array_column($distribution_levels, 'level');
- foreach ($currencys as $currency) {
- $level_arr = [];
- $currency_key = 'distribution_' . $currency;
- $distribution_currency_key[] = $currency_key;
- if (!empty($cashier[$currency_key])) {
- $settings = json_decode($cashier[$currency_key], true);
- $level_arr = array_column($settings, 'level');
- $response[$currency_key] = $settings;
- }
- if(isset($response[$currency_key]) && !empty($response[$currency_key])){
- foreach($response[$currency_key] as $key => $value){
- if(!in_array($value['level'], $now_level_arr)){
- unset($response[$currency_key][$key]);
- }
- }
- $response[$currency_key] = array_values($response[$currency_key]);
- }
- foreach ($distribution_levels as $val) {
- if (!in_array($val['level'], $level_arr)) {
- $response[$currency_key][] = [
- 'level' => $val['level'],
- 'level_name' => $val['level_name'],
- 'commission_rate' => [0, 0],
- ];
- }
- if (isset($response[$currency_key][$val['level']])) {
- $response[$currency_key][$val['level']]['level_name'] = $val['level_name'];
- }
- }
- }
- return compact('response', 'distribution_currency_key');
- }
- protected function getBossSetting($level=[],$boss_levels=[])
- {
- $level_arr=[];
- foreach ($level as $k => $v) {
- $level_arr[$k]['level']=$v['level'];
- $level_arr[$k]['level_name']=$v['level_name'];
- if(count($boss_levels)==0){
- $level_arr[$k]['prize']=0;
- $level_arr[$k]['extra_prize']=0;
- }else{
- foreach ($boss_levels as $val) {
- $i=1;
- if($v['level']==$val['level']){
- $level_arr[$k]['prize']=$val['prize'];
- $level_arr[$k]['extra_prize']=$val['extra_prize'];
- }else{
- $i++;
- }
- if($i>count($level)){
- $level_arr[$k]['prize']=0;
- $level_arr[$k]['extra_prize']=0;
- }
- }
- }
- }
- return $level_arr;
- }
- /**
- * 让利列表
- * @return mixed|string|null
- */
- public function actionReduceProfit()
- {
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isPost) { // 审核
- $setting = $this->request->post();
- // 数据校验
- $res = \Yii::$app->services->validate->validate($setting, [
- [['id', 'status', 'remark'], 'required'],
- [['id', 'status'], 'integer'],
- [['remark'], 'string']
- ], [
- 'id' => '审核对象',
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- try {
- $ret = (new MerchantReduceProfitService())->audit($this->mall_id, $setting['id'],
- $this->admin->id, $setting['status'], $setting['remark']);
- return is_string($ret) ? $this->error($ret) : $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- } else {
- $params = $this->request->post();
- // 数据校验
- $res = \Yii::$app->services->validate->validate($params, [
- [['store_keyword', 'date_start', 'date_end'], 'string'],
- [['rate'], 'number'],
- [['status', 'page', 'limit', 'cate'], 'integer'],
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $ret = (new MerchantReduceProfitService())->page($this->mall_id, $params);
- if (is_array($ret)) {
- $cate_list = StoreCate::find()
- ->select('id,name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- $ret['cate_list'] = $cate_list;
- }
- return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
- }
- }
- return $this->render($this->action->id);
- }
- public function actionScoreStoreApply()
- {
- $search = $this->request->get();
- // 数据校验
- $res = \Yii::$app->services->validate->validate($search, [
- [['store_info', 'store_cate'], 'string'],
- [['check_status', 'score_method', 'page', 'limit'], 'integer'],
- [['date'], 'safe']
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $where = [['mall_id' => $this->mall_id], ['score_method' => $search['score_method'] ?? 1], ['<>', 'status', StatusEnum::DELETE]];
- isset($search['check_status']) && $where[] = ['check_status' => $search['check_status']];
- if (!empty($search['store_info'])) {
- $store_ids = Store::find()->where(['or',
- ['id' => trim($search['store_info'])],
- ['like', 'store_name', trim($search['store_info'])],
- ['like', 'shop_owner', trim($search['store_info'])]
- ])->select('id')->column();
- $where[] = ['store_id' => $store_ids];
- }
- if (!empty($search['date'])) {
- $where[] = ['or', ['between', 'created_at', strtotime($search['date'][0]), strtotime($search['date'][1])], ['between', 'check_time', strtotime($search['date'][0]), strtotime($search['date'][1])]];
- }
- if (!empty($search['store_cate'])) {
- $cate_ids = StoreCate::find()->where(['like', 'name', trim($search['store_cate'])])->select('id')->column();
- $where[] = ['store_c_id' => $cate_ids];
- }
- $result = StoreScoreStoreApply::listPage(['where' => $where, 'page' => $search['page'], 'limit' => $search['limit'], 'with' => ['store' => function ($query) {
- $query->select('id, c_id, store_name, logo_img, shop_owner, shop_mobile, address, ')->with(['cate']);
- }], 'order' => 'created_at desc']);
- if (!empty($result['list'])) {
- $user_ids_arr = array_unique(array_column($result['list'], 'store_user_id'));
- $user_list = \common\models\user\User::lists(['where' => [['id' => $user_ids_arr]], 'index' => 'id', 'select' => 'id, nickname, mobile, avatar_url']);
- foreach ($result['list'] as &$item) {
- $item['user'] = isset($user_list[$item['store_user_id']]) ? $user_list[$item['store_user_id']] : null;
- }
- }
- $result['list'] = $result['list'] ?? [];
- $result['status_map'] = [
- '-1' => '未通过',
- '0' => '待审核',
- '1' => '已通过'
- ];
- return $this->success('获取成功', $result);
- }
- public function actionScoreStoreCheck()
- {
- $trans = \Yii::$app->db->beginTransaction();
- try {
- $request = \Yii::$app->request;
- if (!$request->isPost) throw new \Exception("非法请求");
- $data = $request->post();
- $res = \Yii::$app->services->validate->validate($data, [
- [['id', 'check_status'], 'required'],
- [['id', 'check_status'], 'integer'],
- [['reason'], 'string']
- ]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $model = StoreScoreStoreApply::findOne(['mall_id' => $this->mall_id, 'id' => $data['id'], 'status' => StatusEnum::ENABLED]);
- if (empty($model)) throw new \Exception("当前数据不存在,无法执行修改状态");
- $data['check_time'] = time();
- $model->load($data, '');
- if (!$model->save()) throw new \Exception("修改状态失败,原因:". $model->getErrorMessage());
- if ($data['check_status'] == 1) {
- // 添加门店限制
- if ($model->score_method == 2) {
- $score_deduction_config = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'payment.score_deduction', true);
- $score_deduction_config = json_decode($score_deduction_config, true);
- $score_deduction_config['store_limit_stores_deduction'] = $score_deduction_config['store_limit_stores_deduction'] ?? [];
- $store_limit_stores_deduction = &$score_deduction_config['store_limit_stores_deduction'];
- if (!isset($store_limit_stores_deduction[$model->store_id])) {
- $store_limit_stores_deduction[$model->store_id] = "";
- };
- \Yii::$app->services->setting->addons->set($this->mall_id, StoreEnum::ADDONS_NAME, ['payment' => [
- 'score_deduction' => $score_deduction_config
- ]]);
- $store_limit_stores = array_keys($store_limit_stores_deduction);
- }else {
- $store_limit_stores = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'scoreGive.store_limit_stores', true);
- $store_limit_stores = !empty($store_limit_stores) ? json_decode($store_limit_stores, true) : [];
- if (!in_array($model->store_id, $store_limit_stores)){
- array_unshift($store_limit_stores, (string)$model->store_id);
- };
- \Yii::$app->services->setting->addons->set($this->mall_id, StoreEnum::ADDONS_NAME, ['scoreGive' => [
- 'store_limit_stores' => $store_limit_stores
- ]]);
- }
- }
- $trans->commit();
- return $this->success('修改状态成功', $store_limit_stores ?? []);
- }catch (\Exception $e){
- $trans->rollBack();
- return $this->error($e->getMessage());
- }
- }
- public function actionStoreServiceRatioLog()
- {
- try {
- if (\Yii::$app->request->isAjax) {
- $get = $this->request->get();
- $page = \Yii::$app->request->get('page');
- $limit = \Yii::$app->request->get('limit');
- $wheres[] = ['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED];
- if ($get['keyword']) {
- $store_list = Store::lists([
- 'where' => [
- [
- 'OR',
- ['like', 'store_name', $get['keyword']],
- ['like', 'shop_mobile', $get['keyword']],
- // ['=', 'id', $get['shop_mobile']],
- ],
- ['=', 'mall_id', $this->mall_id]
- ],
- 'select' => 'id'
- ]);
- if ($store_list) {
- $store_ids = array_column($store_list, 'id');
- $wheres[] = ['in', 'store_id', $store_ids];
- }
- }
- if ($get['start_time'] && $get['end_time']) {
- //搜索订单支付时间
- $start_time = strtotime($get['start_time']);
- $end_time = strtotime($get['end_time']);
- $wheres[] = ['between', 'created_at', $start_time, $end_time];
- }
- $with = ['store'];
- $search = [
- 'where' => $wheres,
- 'page' => $page,
- 'order' => 'id desc',
- 'limit' => $limit,
- 'with' => $with,
- ];
- $list = StoreServiceRatioLog::listPage($search);
- return $this->success('success', $list);
- }
- // return $this->render('/store-service-ratio-log/store-service-ratio-log');
- return $this->render($this->action->id);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 获取微信消息模版ID
- * @return mixed|void|null
- * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
- * @throws \GuzzleHttp\Exception\GuzzleException
- */
- public function actionGetWechatNotice()
- {
- if (\Yii::$app->request->isAjax && \Yii::$app->request->post()) {
- $params = \Yii::$app->request->post();
- $res = \Yii::$app->services->validate->validate($params, [
- [['key'], 'required'], [['key'], 'string']
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- // 根据key获取对应的微信消息模板ID
- try {
- $notice_wechat_config = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'notice');
- $notice_wechat = empty($notice_wechat_config['notice_wechat']) ? [] : json_decode($notice_wechat_config['notice_wechat'],true);
- $notice_wechat_template_message_value = $notice_wechat['template_message'] ?? [];
- $tempid = '';
- if(!empty($notice_wechat_template_message_value)){
- if(!empty($notice_wechat_template_message_value[$params['key']]['tempid'])){
- $tempid = $notice_wechat_template_message_value[$params['key']]['tempid'];
- }
- }
- $template = new WechatTemplate($this->mall_id);
- $response = $template->addTemplate($params['key'],$tempid);
- if ($response['errcode'] != 0) return $this->error('获取失败:' . $response['errmsg']);
- return $this->success('获取模板成功,记得左下角按钮进行保存哦', $response['template_id']);
- } catch (\Exception $e) {
- return $this->error('获取失败:' . $e->getMessage());
- }
- }
- }
- }
|