| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers;
- use app\models\AboutArticle;
- use app\models\common\CommonUpload;
- use app\models\MerchantInfo;
- use app\models\ProfitSharingReceiver;
- use app\models\SaasUser;
- use app\models\Salesman;
- use app\models\SmsSetting;
- use app\models\Store;
- use app\models\User;
- use app\models\UploadConfig;
- use app\modules\admin\models\CostProfitListForm;
- use app\modules\admin\models\PlatformProfitCashForm;
- use app\modules\admin\models\ProfitReceiverForm;
- use app\modules\admin\models\ShareFinancialListForm;
- use app\modules\admin\models\ShareProfitListForm;
- use app\modules\admin\models\WechatConfigForm;
- use app\utils\Ocr\OcrApi;
- use Yii;
- use app\modules\admin\models\SaasForm;
- use app\models\Option;
- use yii\base\BaseObject;
- use yii\helpers\Json;
- use app\constants\OptionSetting;
- use app\models\Admin;
- use app\models\SharingReceiver;
- use \app\models\StorePrice;
- use Throwable;
- use yii\web\Response;
- use yii\base\InvalidConfigException;
- use yii\db\StaleObjectException;
- use yii\db\Exception;
- use app\models\SaasStoreReferral;
- use yii\base\NotSupportedException;
- use yii\base\InvalidArgumentException;
- use Exception as GlobalException;
- use app\models\Order;
- use app\models\SaasSupplierReferral;
- use app\models\SaasUserPriceLog;
- use app\models\Supplier;
- class SaasController extends BaseController
- {
- // 获取基础配置
- public function actionGetBaseSetting()
- {
- if (\Yii::$app->isSaas()) {
- $admin_logo = Option::get('admin_logo', 0, 'saas', '');
- $admin_copyright = Option::get('admin_copyright', 0, 'saas', '');
- $admin_name = Option::get('name', 0, 'saas', '');
- $help_logo = Option::get('help_logo', 0, 'saas', '');
- $describe = Option::get('describe', 0, 'saas', '');
- } else {
- $store_id = get_store_id();
- $admin_logo = Option::get('web_log', $store_id, 'web', '');
- $admin_copyright = Option::get('copyright', $store_id, 'web', '');
- $admin_name = Option::get('web_name', $store_id, 'web', '');
- $help_logo = Option::get('help_logo', $store_id, 'web', '');
- $describe = Option::get('describe', $store_id, 'web', '');
- $passport_bg = Option::get('passport_bg', $store_id, 'web', '');
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'admin_logo' => $admin_logo['value'],
- 'admin_copyright' => $admin_copyright['value'],
- 'admin_name' => $admin_name['value'],
- 'help_logo' => $help_logo['value'],
- 'describe' => $describe['value'],
- 'passport_bg' => $passport_bg['value'] ?? null
- ],
- ]);
- }
- public function actionSetPlatformAppParams() {
- try {
- if (\Yii::$app->request->isPost) {
- $key = [
- 'platform_app_store_android',
- 'platform_app_store_android_version',
- 'platform_app_store_ios',
- 'platform_app_logo',
- 'platform_app_bg',
- ];
- $params = post_params();
- $value = [
- $params['platform_app_store_android'],
- $params['platform_app_store_android_version'],
- $params['platform_app_store_ios'],
- $params['platform_app_logo'],
- $params['platform_app_bg'],
- ];
- Option::set($key, $value, 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => ''
- ]);
- } else {
- $keys = [
- 'platform_app_store_android',
- 'platform_app_store_android_version',
- 'platform_app_store_ios',
- 'platform_app_logo',
- 'platform_app_bg',
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'platform_app_store_android' => '',
- 'platform_app_store_android_version' => '',
- 'platform_app_store_ios' => '',
- 'platform_app_logo' => '',
- 'platform_app_bg' => '',
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- $data = $arr;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- } catch (\Exception $e) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $e->getMessage()
- ]);
- }
- }
- public function actionOneStoreWechatSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $appid = post_params('one_store_wechat_appid', '');
- $secret = post_params('one_store_wechat_secret', '');
- $is_shenhe = post_params('one_store_is_shenhe', false);
- $switch_store = post_params('one_store_switch_store', false);
- $default_store = post_params('one_store_default_store', 0);
- $show_apply = post_params('one_store_hide_apply', 0);
- $one_store_lock_store = post_params('one_store_lock_store', 0);
- $mch_id = post_params('one_store_mch_id', '');
- $pay_key = post_params('one_store_pay_key', '');
- $apiclient_cert = post_params('one_store_apiclient_cert', '');
- $apiclient_key = post_params('one_store_apiclient_key', '');
- $apiclient_cert_url = post_params('one_store_apiclient_cert_url', '');
- $apiclient_key_url = post_params('one_store_apiclient_key_url', '');
- if (!empty($apiclient_cert_url)) {
- $apiclient_cert = file_get_contents($apiclient_cert_url);
- } else {
- if (!empty($apiclient_cert)) {
- $apiclient_cert_url = WechatConfigForm::handlePemFile($apiclient_cert);
- }
- }
- if (!empty($apiclient_key_url)) {
- $apiclient_key = file_get_contents($apiclient_key_url);
- } else {
- if (!empty($apiclient_key)) {
- $apiclient_key_url = WechatConfigForm::handlePemFile($apiclient_key);
- }
- }
- $app_appid = post_params('one_store_app_wechat_appid', '');
- $app_secret = post_params('one_store_app_wechat_secret', '');
- $app_mch_id = post_params('one_store_app_mch_id', '');
- $app_pay_key = post_params('one_store_app_pay_key', '');
- $app_apiclient_cert = post_params('one_store_app_apiclient_cert', '');
- $app_apiclient_key = post_params('one_store_app_apiclient_key', '');
- $app_apiclient_cert_url = post_params('one_store_app_apiclient_cert_url', '');
- $app_apiclient_key_url = post_params('one_store_app_apiclient_key_url', '');
- if (!empty($app_apiclient_cert_url)) {
- $app_apiclient_cert = file_get_contents($app_apiclient_cert_url);
- } else {
- if (!empty($app_apiclient_cert)) {
- $app_apiclient_cert_url = WechatConfigForm::handlePemFile($app_apiclient_cert);
- }
- }
- if (!empty($app_apiclient_key_url)) {
- $app_apiclient_key = file_get_contents($app_apiclient_key_url);
- } else {
- if (!empty($app_apiclient_key)) {
- $app_apiclient_key_url = WechatConfigForm::handlePemFile($app_apiclient_key);
- }
- }
- $one_store_app_android = post_params('one_store_app_android', '');//app下载地址 android版本
- $one_store_app_android_version = post_params('one_store_app_android_version', '');//安卓app版本
- $one_store_app_ios = post_params('one_store_app_ios', '');//app包下载地址 ios版本
- $one_store_wechat_h5_sub_mch_id = post_params('one_store_wechat_h5_sub_mch_id', '');
- $one_store_wechat_official_appid = post_params('one_store_wechat_official_appid', '');
- $one_store_wechat_official_secret = post_params('one_store_wechat_official_secret', '');
- $one_store_wechat_official_token = post_params('one_store_wechat_official_token', '');
- $one_store_wechat_official_auto_reply = post_params('one_store_wechat_official_auto_reply', '');
- $one_store_official_pay_key = post_params('one_store_official_pay_key', '');
- $one_store_official_apiclient_cert_url = post_params('one_store_official_apiclient_cert_url', '');
- $one_store_official_apiclient_key_url = post_params('one_store_official_apiclient_key_url', '');
- $one_store_official_apiclient_cert = post_params('one_store_official_apiclient_cert', '');
- $one_store_official_apiclient_key = post_params('one_store_official_apiclient_key', '');
- $one_store_wechat_official_sub_mch_id = post_params('one_store_wechat_official_sub_mch_id', '');
- if (!empty($one_store_official_apiclient_cert_url)) {
- $one_store_official_apiclient_cert = file_get_contents($one_store_official_apiclient_cert_url);
- } else {
- if (!empty($one_store_official_apiclient_cert)) {
- $one_store_official_apiclient_cert_url = WechatConfigForm::handlePemFile($one_store_official_apiclient_cert);
- }
- }
- if (!empty($one_store_official_apiclient_key_url)) {
- $one_store_official_apiclient_key = file_get_contents($one_store_official_apiclient_key_url);
- } else {
- if (!empty($one_store_official_apiclient_key)) {
- $one_store_official_apiclient_key_url = WechatConfigForm::handlePemFile($one_store_official_apiclient_key);
- }
- }
- //供应链App包上传以及版本管理
- $alipay = post_params('alipay');
- Option::set('one_store_alipay_config', json_encode($alipay), 0, 'saas');
- Option::set('one_store_wechat_appid', $appid, 0, 'saas');
- Option::set('one_store_wechat_secret', $secret, 0, 'saas');
- Option::set('one_store_is_shenhe', $is_shenhe ? 1 : 0, 0, 'saas');
- Option::set('one_store_switch_store', $switch_store ? 1 : 0, 0, 'saas');
- Option::set('one_store_default_store', $default_store, 0, 'saas');
- Option::set('one_store_mch_id', $mch_id, 0, 'saas');
- Option::set('one_store_pay_key', $pay_key, 0, 'saas');
- Option::set('one_store_apiclient_cert', $apiclient_cert, 0, 'saas');
- Option::set('one_store_apiclient_key', $apiclient_key, 0, 'saas');
- Option::set('one_store_apiclient_cert_url', $apiclient_cert_url, 0, 'saas');
- Option::set('one_store_apiclient_key_url', $apiclient_key_url, 0, 'saas');
- Option::set('one_store_hide_apply', $show_apply, 0, 'saas');
- Option::set('one_store_lock_store', $one_store_lock_store, 0, 'saas');
- //app配置
- Option::set('one_store_app_wechat_appid', $app_appid, 0, 'saas');
- Option::set('one_store_app_wechat_secret', $app_secret, 0, 'saas');
- Option::set('one_store_app_mch_id', $app_mch_id, 0, 'saas');
- Option::set('one_store_app_pay_key', $app_pay_key, 0, 'saas');
- Option::set('one_store_app_apiclient_cert', $app_apiclient_cert, 0, 'saas');
- Option::set('one_store_app_apiclient_key', $app_apiclient_key, 0, 'saas');
- Option::set('one_store_app_apiclient_cert_url', $app_apiclient_cert_url, 0, 'saas');
- Option::set('one_store_app_apiclient_key_url', $app_apiclient_key_url, 0, 'saas');
- Option::set('one_store_app_android', $one_store_app_android, 0, 'saas');
- Option::set('one_store_app_android_version', $one_store_app_android_version, 0, 'saas');
- Option::set('one_store_app_ios', $one_store_app_ios, 0, 'saas');
- Option::set('one_store_wechat_h5_sub_mch_id', $one_store_wechat_h5_sub_mch_id, 0, 'saas');
- //供应链
- Option::set('one_store_wechat_official_appid', $one_store_wechat_official_appid, 0, 'saas');
- Option::set('one_store_wechat_official_secret', $one_store_wechat_official_secret, 0, 'saas');
- Option::set('one_store_wechat_official_token', $one_store_wechat_official_token, 0, 'saas');
- Option::set('one_store_wechat_official_auto_reply', $one_store_wechat_official_auto_reply, 0, 'saas');
- Option::set('one_store_official_pay_key', $one_store_official_pay_key, 0, 'saas');
- Option::set('one_store_official_apiclient_cert_url', $one_store_official_apiclient_cert_url, 0, 'saas');
- Option::set('one_store_official_apiclient_key_url', $one_store_official_apiclient_key_url, 0, 'saas');
- Option::set('one_store_official_apiclient_cert', $one_store_official_apiclient_cert, 0, 'saas');
- Option::set('one_store_official_apiclient_key', $one_store_official_apiclient_key, 0, 'saas');
- Option::set('one_store_wechat_official_sub_mch_id', $one_store_wechat_official_sub_mch_id, 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- }
- $appid = Option::get('one_store_wechat_appid', 0, 'saas', '');
- $secret = Option::get('one_store_wechat_secret', 0, 'saas', '');
- $is_shenhe = Option::get('one_store_is_shenhe', 0, 'saas', 0);
- $switch_store = Option::get('one_store_switch_store', 0, 'saas', 0);
- $default_store = Option::get('one_store_default_store', 0, 'saas', 1)['value'];
- $mch_id = Option::get('one_store_mch_id', 0, 'saas', '');
- $pay_key = Option::get('one_store_pay_key', 0, 'saas', '');
- $apiclient_cert = Option::get('one_store_apiclient_cert', 0, 'saas', '');
- $apiclient_key = Option::get('one_store_apiclient_key', 0, 'saas', '');
- $apiclient_cert_url = Option::get('one_store_apiclient_cert_url', 0, 'saas', '')['value'];
- $apiclient_key_url= Option::get('one_store_apiclient_key_url', 0, 'saas', '')['value'];
- if (empty($apiclient_cert_url) && !empty($apiclient_cert['value'])) {
- $apiclient_cert_url = WechatConfigForm::handlePemFile($apiclient_cert['value']);
- }
- if (empty($apiclient_key_url) && !empty($apiclient_key['value'])) {
- $apiclient_key_url = WechatConfigForm::handlePemFile($apiclient_key['value']);
- }
- $alipay = Option::get('one_store_alipay_config', 0, 'saas', '')['value'];
- $show_apply = Option::get('one_store_hide_apply', 0, 'saas', '0');
- $one_store_lock_store = Option::get('one_store_lock_store', 0, 'saas', '0');
- $app_appid = Option::get('one_store_app_wechat_appid', 0, 'saas', '');
- $app_secret = Option::get('one_store_app_wechat_secret', 0, 'saas', '');
- $app_mch_id = Option::get('one_store_app_mch_id', 0, 'saas', '');
- $app_pay_key = Option::get('one_store_app_pay_key', 0, 'saas', '');
- $app_apiclient_cert = Option::get('one_store_app_apiclient_cert', 0, 'saas', '');
- $app_apiclient_key = Option::get('one_store_app_apiclient_key', 0, 'saas', '');
- $app_apiclient_cert_url = Option::get('one_store_app_apiclient_cert_url', 0, 'saas', '')['value'];
- $app_apiclient_key_url = Option::get('one_store_app_apiclient_key_url', 0, 'saas', '')['value'];
- if (empty($app_apiclient_cert_url) && !empty($app_apiclient_cert['value'])) {
- $app_apiclient_cert_url = WechatConfigForm::handlePemFile($app_apiclient_cert['value']);
- }
- if (empty($app_apiclient_key_url) && !empty($app_apiclient_key['value'])) {
- $app_apiclient_key_url = WechatConfigForm::handlePemFile($app_apiclient_key['value']);
- }
- $one_store_app_android = Option::get('one_store_app_android', 0, 'saas', '');
- $one_store_app_android_version = Option::get('one_store_app_android_version', 0, 'saas', '');
- $one_store_app_ios = Option::get('one_store_app_ios', 0, 'saas', '');
- $one_store_wechat_h5_sub_mch_id = Option::get('one_store_wechat_h5_sub_mch_id', 0, 'saas', '');
- $one_store_wechat_official_appid = Option::get('one_store_wechat_official_appid', 0, 'saas', '');
- $one_store_wechat_official_secret = Option::get('one_store_wechat_official_secret', 0, 'saas', '');
- $one_store_wechat_official_token = Option::get('one_store_wechat_official_token', 0, 'saas', '');
- $one_store_wechat_official_auto_reply = Option::get('one_store_wechat_official_auto_reply', 0, 'saas', '');
- //供应链公众号设置需要显示服务器地址以及支付目录
- $one_store_official_server_url = 'https://' . \Yii::$app->request->hostName . '/index.php?r=common/wechat-callback/index&store_id=0';
- $one_store_official_pay_url = 'https://' . \Yii::$app->request->hostName . '/';
- $one_store_official_pay_key = Option::get('one_store_official_pay_key', 0, 'saas', '');
- $one_store_official_apiclient_cert_url = Option::get('one_store_official_apiclient_cert_url', 0, 'saas', '');
- $one_store_official_apiclient_key_url = Option::get('one_store_official_apiclient_key_url', 0, 'saas', '');
-
- $one_store_official_apiclient_cert = Option::get('one_store_official_apiclient_cert', 0, 'saas', '');
- $one_store_official_apiclient_key = Option::get('one_store_official_apiclient_key', 0, 'saas', '');
-
- $one_store_wechat_official_sub_mch_id = Option::get('one_store_wechat_official_sub_mch_id', 0, 'saas', '');
- if (empty($alipay)) {
- $alipay = [
- 'aes_key' => '',
- 'alipay_public_key' => '',
- 'app_id' => '',
- 'app_private_key' => '',
- 'app_public_key' => '',
- 'name' => '',
- 'user_id' => '',
- 'one_store_is_shenhe' => false,
- 'one_store_lock_store' => 0
- ];
- } else {
- $alipay = json_decode($alipay, true);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'one_store_wechat_appid' => $appid['value'],
- 'one_store_wechat_secret' => $secret['value'],
- 'one_store_is_shenhe' => (bool)$is_shenhe['value'],
- 'one_store_switch_store' => (bool)$switch_store['value'],
- 'one_store_default_store' => $default_store ?: '1',
- 'one_store_mch_id' => $mch_id['value'],
- 'one_store_pay_key' => $pay_key['value'],
- 'one_store_apiclient_cert' => $apiclient_cert['value'],
- 'one_store_apiclient_key' => $apiclient_key['value'],
- 'one_store_apiclient_cert_url' => $apiclient_cert_url,
- 'one_store_apiclient_key_url' => $apiclient_key_url,
- 'alipay' => $alipay,
- 'one_store_hide_apply' => (string)$show_apply['value'],
- 'one_store_lock_store' => (int)$one_store_lock_store['value'],
- 'one_store_app_wechat_appid' => $app_appid['value'],
- 'one_store_app_wechat_secret' => $app_secret['value'],
- 'one_store_app_mch_id' => $app_mch_id['value'],
- 'one_store_app_pay_key' => $app_pay_key['value'],
- 'one_store_app_apiclient_cert' => $app_apiclient_cert['value'],
- 'one_store_app_apiclient_key' => $app_apiclient_key['value'],
- 'one_store_app_apiclient_cert_url' => $app_apiclient_cert_url,
- 'one_store_app_apiclient_key_url' => $app_apiclient_key_url,
- 'one_store_app_android' => $one_store_app_android['value'],
- 'one_store_app_android_version' => $one_store_app_android_version['value'],
- 'one_store_app_ios' => $one_store_app_ios['value'],
- 'one_store_wechat_h5_sub_mch_id' => $one_store_wechat_h5_sub_mch_id['value'],
- 'one_store_wechat_official_appid' => $one_store_wechat_official_appid['value'],
- 'one_store_wechat_official_secret' => $one_store_wechat_official_secret['value'],
- 'one_store_wechat_official_token' => $one_store_wechat_official_token['value'],
- 'one_store_wechat_official_auto_reply' => $one_store_wechat_official_auto_reply['value'],
- 'one_store_official_server_url' => $one_store_official_server_url,
- 'one_store_official_pay_url' => $one_store_official_pay_url,
- 'one_store_official_pay_key' => $one_store_official_pay_key['value'],
- 'one_store_official_apiclient_cert_url' => $one_store_official_apiclient_cert_url['value'],
- 'one_store_official_apiclient_key_url' => $one_store_official_apiclient_key_url['value'],
-
- 'one_store_official_apiclient_cert' => $one_store_official_apiclient_cert['value'],
- 'one_store_official_apiclient_key' => $one_store_official_apiclient_key['value'],
-
- 'one_store_wechat_official_sub_mch_id' => $one_store_wechat_official_sub_mch_id['value'],
- ],
- ]);
- }
- /**
- * 设置联盟入驻协议
- *
- */
- public function actionUnionProtocol()
- {
- if (Yii::$app->request->getIsPost()) {
- $protocol = post_params('protocol', '');
- $is_debug = post_params('is_debug', 0);
- $describe = post_params('describe', '');
- $name = post_params('name', '');
- $logo = post_params('logo', '');
- $help_logo = post_params('help_logo', '');
- $union_client_loading_logo = post_params('union_client_loading_logo', '');
- $admin_logo = post_params('admin_logo', '');
- $admin_copyright = post_params('admin_copyright', '');
- $search_keyword = post_params('search_keyword', []);
- $lang = post_params('lang', 'zh-CN');
- $shenhe = post_params('shenhe', 0);
- $is_show_kefu_download = post_params('is_show_kefu_download', 1);
- // $tencent_map_key = post_params('tencent_map_key', '');
- Option::set('is_debug', $is_debug, 0, 'saas');
- Option::set('protocol', $protocol, 0, 'saas');
- Option::set('store_apply_agreement', $protocol, 0, 'saas');
- Option::set('describe', $describe, 0, 'saas');
- Option::set('name', $name, 0, 'saas');
- Option::set('logo', $logo, 0, 'saas');
- Option::set('help_logo', $help_logo, 0, 'saas');
- Option::set('union_client_loading_logo', $union_client_loading_logo, 0, 'saas');
- Option::set('admin_copyright', $admin_copyright, 0, 'saas');
- Option::set('admin_logo', $admin_logo, 0, 'saas');
- Option::set('lang', $lang, 0, 'saas');
- Option::set('lang', $lang, 0, 'saas');
- Option::set('search_keyword', json_encode($search_keyword), 0, 'saas');
- Option::set('shenhe', $shenhe, 0, 'saas');
- Option::set('is_show_kefu_download', $is_show_kefu_download, 0, 'saas');
- // Option::set('tencent_map_key', $tencent_map_key, 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $is_debug = Option::get('is_debug', 0, 'saas', '');
- $protocol = Option::get('protocol', 0, 'saas', '');
- $describe = Option::get('describe', 0, 'saas', '');
- $name = Option::get('name', 0, 'saas', '');
- $logo = Option::get('logo', 0, 'saas', '');
- $help_logo = Option::get('help_logo', 0, 'saas', '');
- $union_client_loading_logo = Option::get('union_client_loading_logo', 0, 'saas', '');
- $admin_logo = Option::get('admin_logo', 0, 'saas', '');
- $admin_copyright = Option::get('admin_copyright', 0, 'saas', '');
- $lang = Option::get('lang', 0, 'saas', 'zh-CN');
- $search_keyword = Option::get('search_keyword', 0, 'saas', json_encode([]));
- $shenhe = Option::get('shenhe', 0, 'saas', 0);
- $is_show_kefu_download = Option::get('is_show_kefu_download', 0, 'saas', 1);
- // $tencent_map_key = Option::get('tencent_map_key', 0, 'saas', '');
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'is_debug'=>$is_debug['value'],
- 'protocol' => $protocol['value'],
- 'describe' => $describe['value'],
- 'name' => $name['value'],
- 'logo' => $logo['value'],
- 'help_logo' => $help_logo['value'],
- 'union_client_loading_logo' => $union_client_loading_logo['value'],
- 'admin_logo' => $admin_logo['value'],
- 'admin_copyright' => $admin_copyright['value'],
- 'lang' => $lang['value'],
- 'shenhe' => (int)$shenhe['value'],
- 'search_keyword' => json_decode($search_keyword['value']),
- 'is_show_kefu_download' => intval($is_show_kefu_download['value'])
- // 'tencent_map_key' => $tencent_map_key['value']
- ]
- ]);
- }
- }
- public function actionUnionProtocolStore()
- {
- if(\Yii::$app->isSaas()){
- // return;
- }
- if (Yii::$app->request->getIsPost()) {
- $describe = post_params('describe', '');
- $help_logo = post_params('help_logo', '');
- Option::set('describe', $describe, 0, 'saas');
- Option::set('help_logo', $help_logo, 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $describe = Option::get('describe', 0, 'saas', '');
- $help_logo = Option::get('help_logo', 0, 'saas', '');
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'describe' => $describe['value'],
- 'help_logo' => $help_logo['value'],
- ]
- ]);
- }
- }
- public function actionSaasMapSetting() {
- $tencent_map_key = Option::get('tencent_map_key', 0, 'saas', '');
- if (Yii::$app->request->getIsPost()) {
- $tencent_map_key = post_params('tencent_map_key', '');
- $amap_key = post_params('amap_key', '');
- $amap_security_js_code = post_params('amap_security_js_code', '');
- $amap_service_host = post_params('amap_service_host', '');
- Option::set('tencent_map_key', $tencent_map_key, 0, 'saas');
- Option::set('amap_key', $amap_key, 0, 'saas');
- Option::set('amap_security_js_code', $amap_security_js_code, 0, 'saas');
- Option::set('amap_service_host', $amap_service_host, 0, 'saas');
- // 更新h5的腾讯地图key
- \app\utils\UpdateAfter::UpdateQQMapKey($tencent_map_key);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $amap_key = Option::get('amap_key', 0, 'saas', '');
- $amap_security_js_code = Option::get('amap_security_js_code', 0, 'saas', '');
- $amap_service_host = Option::get('amap_service_host', 0, 'saas', '');
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'tencent_map_key' => $tencent_map_key['value'],
- 'amap_key' => $amap_key['value'],
- 'amap_security_js_code' => $amap_security_js_code['value'],
- 'amap_service_host' => $amap_service_host['value'],
- ]
- ]);
- }
- }
- /**
- * 设置银行卡信息(服务商)
- *
- * @return void
- */
- public function actionBankSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $conf = post_params('conf', []);
- $set = SaasForm::bankSettingSave(1, 0, $conf);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- 'set' => $set,
- ]);
- } else {
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => SaasForm::bankSetting(1),
- 'store_id' => get_store_id(),
- ]);
- }
- }
- /**
- * 设置通联配置信息(服务商)
- *
- * @return void
- */
- public function actionYunstSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $conf = post_params('content', []);
- $set = SaasForm::yunstSettingSave(1, 0, $conf);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- 'set' => $set,
- ]);
- } else {
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => SaasForm::yunstSetting(1),
- 'store_id' => get_store_id(),
- ]);
- }
- }
- /**
- * 设置银行卡信息(店铺)
- *
- * @return void
- */
- public function actionStoreBankSetting()
- {
- $store_id = get_store_id();
- if (Yii::$app->request->getIsPost()) {
- $conf = post_params('conf', []);
- $set = SaasForm::bankSettingSave(0, $store_id, $conf);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- 'set' => $set,
- ]);
- } else {
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => SaasForm::bankSetting(0, $store_id),
- 'store_id' => get_store_id(),
- ]);
- }
- }
- /**
- * 设置线下转账信息(店铺)
- *
- * @return void
- */
- public function actionOfflineSetting()
- {
- $store_id = get_store_id();
- if (Yii::$app->request->getIsPost()) {
- $conf = post_params('conf', []);
- $set = SaasForm::offlineSettingSave($store_id, $conf);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- 'set' => $set,
- ]);
- } else {
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => ['conf' => SaasForm::offlineSetting($store_id)],
- 'store_id' => get_store_id(),
- ]);
- }
- }
- /**
- * 设置微信支付信息(服务商)
- *
- * @return void
- */
- public function actionWechatSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $sp_name = post_params('sp_name', '');
- $sp_appid = post_params('sp_appid', '');
- $sp_mch_id = post_params('sp_mch_id', '');
- $sp_key = post_params('sp_key', '');
- $sp_apiclient_cert = post_params('sp_apiclient_cert', '');
- $sp_apiclient_key = post_params('sp_apiclient_key', '');
- $sp_apiclient_cert_url = post_params('sp_apiclient_cert_url', '');
- $sp_apiclient_key_url = post_params('sp_apiclient_key_url', '');
- if (!empty($sp_apiclient_cert_url)) {
- $sp_apiclient_cert = file_get_contents($sp_apiclient_cert_url);
- } else {
- if (!empty($sp_apiclient_cert)) {
- $sp_apiclient_cert_url = WechatConfigForm::handlePemFile($sp_apiclient_cert);
- }
- }
- if (!empty($sp_apiclient_key_url)) {
- $sp_apiclient_key = file_get_contents($sp_apiclient_key_url);
- } else {
- if (!empty($sp_apiclient_key)) {
- $sp_apiclient_key_url = WechatConfigForm::handlePemFile($sp_apiclient_key);
- }
- }
- $platform_public_key = post_params('platform_public_key', '');
- $platform_public_key_id = post_params('platform_public_key_id', '');
- $platform_api_key = post_params('platform_api_key', '');
- $platform_serial_no = post_params('platform_serial_no', '');
- $pay_rate = post_params('pay_rate', '0.2');
- $pay_rate = sprintf('%.2f', $pay_rate); //保留两位
- //$pay_rate < 0.2 ||
- if ($pay_rate < 0 || $pay_rate > 0.6) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '默认支付费率应在0 ~ 0.6区间',
- ]);
- }
- Option::set([
- 'sp_name',
- 'sp_appid',
- 'sp_mch_id',
- 'sp_key',
- 'sp_apiclient_cert',
- 'sp_apiclient_key',
- 'sp_apiclient_cert_url',
- 'sp_apiclient_key_url',
- 'platform_public_key',
- 'platform_public_key_id',
- 'platform_api_key',
- 'platform_serial_no',
- 'pay_rate'
- ], [
- $sp_name,
- $sp_appid,
- $sp_mch_id,
- $sp_key,
- $sp_apiclient_cert,
- $sp_apiclient_key,
- $sp_apiclient_cert_url,
- $sp_apiclient_key_url,
- $platform_public_key,
- $platform_public_key_id,
- $platform_api_key,
- $platform_serial_no,
- $pay_rate
- ], 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $keys = [
- 'sp_name',
- 'sp_appid',
- 'sp_mch_id',
- 'sp_key',
- 'sp_apiclient_cert',
- 'sp_apiclient_key',
- 'sp_apiclient_cert_url',
- 'sp_apiclient_key_url',
- 'platform_public_key',
- 'platform_public_key_id',
- 'platform_api_key',
- 'platform_serial_no',
- 'pay_rate'
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'sp_name' => '',
- 'sp_appid' => '',
- 'sp_mch_id' => '',
- 'sp_key' => '',
- 'sp_apiclient_cert' => '',
- 'sp_apiclient_key' => '',
- 'sp_apiclient_cert_url' => '',
- 'sp_apiclient_key_url' => '',
- 'platform_public_key'=>"",
- 'platform_public_key_id'=>"",
- 'platform_api_key'=>"",
- 'platform_serial_no'=>"",
- 'pay_rate' => '0.2'
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- if (empty($arr['sp_apiclient_cert_url']) && !empty($arr['sp_apiclient_cert'])) {
- $arr['sp_apiclient_cert_url'] = WechatConfigForm::handlePemFile($arr['sp_apiclient_cert']);
- }
- if (empty($arr['sp_apiclient_key_url']) && !empty($arr['sp_apiclient_key'])) {
- $arr['sp_apiclient_key_url'] = WechatConfigForm::handlePemFile($arr['sp_apiclient_key']);
- }
- $data = $arr;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置地址识别配置
- *
- * @return void
- */
- public function actionAddressRecognitionSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $kuaidi100_secret_key = post_params(OptionSetting::KUAIDI100_SECRET_KEY, '');
- $kuaidi100_secret_code = post_params(OptionSetting::KUAIDI100_SECRET_CODE, '');
- $kuaidi100_secret_secret = post_params(OptionSetting::KUAIDI100_SECRET_SECRET, '');
- $kuaidi100_secret_sign = post_params(OptionSetting::KUAIDI100_SECRET_SIGN, '');
- Option::set([
- OptionSetting::KUAIDI100_SECRET_KEY,
- OptionSetting::KUAIDI100_SECRET_CODE,
- OptionSetting::KUAIDI100_SECRET_SECRET,
- OptionSetting::KUAIDI100_SECRET_SIGN
- ], [
- $kuaidi100_secret_key,
- $kuaidi100_secret_code,
- $kuaidi100_secret_secret,
- $kuaidi100_secret_sign,
- ], 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $keys = [
- OptionSetting::KUAIDI100_SECRET_KEY,
- OptionSetting::KUAIDI100_SECRET_CODE,
- OptionSetting::KUAIDI100_SECRET_SECRET,
- OptionSetting::KUAIDI100_SECRET_SIGN,
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- OptionSetting::KUAIDI100_SECRET_KEY => '',
- OptionSetting::KUAIDI100_SECRET_CODE => '',
- OptionSetting::KUAIDI100_SECRET_SECRET => '',
- OptionSetting::KUAIDI100_SECRET_SIGN => '',
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- $data = $arr;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 店铺缴费设置
- *
- * @return void
- */
- public function actionStoreReOrder()
- {
- if (Yii::$app->request->getIsPost()) {
- $open_price = post_params('open_price', '0.00');
- $profit = post_params('profit', '0.00');
- $renew_price = post_params('renew_price', '0.00');
- Option::set([
- 'open_price',
- 'profit',
- 'renew_price'
- ], [
- $open_price,
- $profit,
- $renew_price,
- ], 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $keys = [
- 'open_price',
- 'profit',
- 'renew_price'
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'open_price' => '0.00',
- 'profit' => '0.00',
- 'renew_price' => '0.00'
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- $data = $arr;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 店铺让利比例设置
- *
- * @return void
- */
- public function actionStoreTransferProfitParams()
- {
- if (Yii::$app->request->getIsPost()) {
- $transfer_profit = post_params('transfer_profit', '0.00');
- Option::set([
- 'transfer_profit'
- ], [
- $transfer_profit
- ], -1, OptionSetting::SHARE_GROUP_NAME);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $data = Option::get('transfer_profit', -1, OptionSetting::SHARE_GROUP_NAME)['value'];
- if (empty($data)) {
- $data = '0.00';
- } else {
- $data = json_decode($data, true);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 店铺分销默认设置
- *
- * @return void
- */
- public function actionStoreDefaultParams()
- {
- $data = Option::get(OptionSetting::SHARE_STORE_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME)['value'];
- if (empty($data)) {
- $data = [
- 'store_share_switch' => '0',
- 'store_share_type' => '0',
- 'store_share_value' => '0'
- ];
- } else {
- $data = json_decode($data, true);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- public function actionGetProfitSetting()
- {
- // $store_recharge_profit_model = Option::findOne(['name' => 'store_recharge_profit']);
- $store_profit_max_model = Option::findOne(['name' => 'store_profit_max']);
- $store_profit_min_model = Option::findOne(['name' => 'store_profit_min']);
- $store_send_min_model = Option::findOne(['name' => 'store_send_min']);
- // $store_send_profit_model = Option::findOne(['name' => 'store_send_profit']);
- $data = [
- // 'store_recharge_profit' => $store_recharge_profit_model->value,
- 'store_profit_max' => $store_profit_max_model->value,
- 'store_profit_min' => $store_profit_min_model->value,
- 'store_send_min' => $store_send_min_model->value,
- 'store_send_profit' => 100,
- ];
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- /**
- * 联盟分销默认设置
- *
- * @return void
- */
- public function actionSaasDefaultParams()
- {
- $data = Option::get(OptionSetting::SHARE_SAAS_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME)['value'];
- if (empty($data)) {
- $data = [
- 'is_rebate' => 0,
- 'level' => 1,
- 'level_one' => "0.00",
- 'level_three' => "0.00",
- 'level_two' => "0.00",
- 'price_type' => 0
- ];
- } else {
- $data = json_decode($data, true);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- /**
- * 店铺推荐人分销默认设置
- *
- * @return void
- */
- public function actionSaasReferralDefaultParams()
- {
- $data = Option::get(OptionSetting::SHARE_SAAS_REFERRAL_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME)['value'];
- if (empty($data)) {
- $data = [
- 'is_enable' => '0',
- 'referral_rebate' => '0'
- ];
- } else {
- $data = json_decode($data, true);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- /**
- * 供货商推荐人分销默认设置
- *
- * @return void
- */
- public function actionSaasSupplierReferralDefaultParams()
- {
- $data = Option::get(OptionSetting::SHARE_SAAS_SUPPLIER_REFERRAL_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME)['value'];
- if (empty($data)) {
- $data = [
- 'is_enable' => '0',
- 'referral_rebate' => '0'
- ];
- } else {
- $data = json_decode($data, true);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- /**
- * 消费返利分销默认设置
- *
- * @return void
- */
- public function actionSelfRebateDefaultParams()
- {
- $data = Option::get(OptionSetting::SHARE_SELF_REBATE_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME)['value'];
- if (empty($data)) {
- $data = [
- 'self_rebate_switch' => '0',
- 'self_rebate_value' => '0'
- ];
- } else {
- $data = json_decode($data, true);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- /**
- * 设置支付宝商盟小程序客户端
- *
- */
- public function actionAlipayPlatformSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $info = post_params();
- $info = json_encode($info);
- Option::set([
- 'alipay_platform',
- ], [
- $info
- ], 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- }else{
- $keys = [
- 'alipay_platform'
- ];
- $data = Option::get($keys, 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => isset($data[0]) ? json_decode($data[0]['value'],true) : NULL
- ]);
- }
- }
- /**
- * 设置支付宝服务商
- *
- */
- public function actionAlipaySetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $alipay_appid = post_params('alipay_appid', '');
- $alipay_public_key = post_params('alipay_public_key', '');
- $alipay_app_public_key = post_params('alipay_app_public_key', '');
- $alipay_app_private_key = post_params('alipay_app_private_key', '');
- $alipay_user_id = post_params('alipay_user_id', '');
- $alipay_aes_key = post_params('alipay_aes_key', '');
- $name = post_params('alipay_name', '');
- if (empty($alipay_user_id) || empty($name)) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '务必完善企业名称和USER_ID'
- ]);
- }
- Option::set([
- 'alipay_appid',
- 'alipay_public_key',
- 'alipay_app_public_key',
- 'alipay_app_private_key',
- 'alipay_user_id',
- 'alipay_name',
- 'alipay_aes_key'
- ], [
- $alipay_appid,
- $alipay_public_key,
- $alipay_app_public_key,
- $alipay_app_private_key,
- $alipay_user_id,
- $name,
- $alipay_aes_key
- ], 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $keys = [
- 'alipay_appid',
- 'alipay_public_key',
- 'alipay_app_public_key',
- 'alipay_app_private_key',
- 'alipay_user_id',
- 'alipay_name',
- 'alipay_aes_key'
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'alipay_appid' => '',
- 'alipay_public_key' => '',
- 'alipay_app_public_key' => '',
- 'alipay_app_private_key' => '',
- 'alipay_user_id' => '',
- 'alipay_name' => '',
- 'alipay_aes_key'=>''
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- $data = $arr;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置微信支付信息(用于提现)
- *
- * @return void
- */
- public function actionWechatPlatformSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $platform_app_appid = post_params('platform_app_appid', '');
- $platform_appid = post_params('platform_appid', '');
- $platform_mch_id = post_params('platform_mch_id', '');
- $platform_key = post_params('platform_key', '');
- $platform_apiclient_cert = post_params('platform_apiclient_cert', '');
- $platform_apiclient_key = post_params('platform_apiclient_key', '');
- $platform_apiclient_cert_url = post_params('platform_apiclient_cert_url', '');
- $platform_apiclient_key_url = post_params('platform_apiclient_key_url', '');
- $platform_pay_key = post_params('platform_pay_key', '');
- $platform_gh_id = post_params('platform_gh_id', '');
- if (!empty($platform_apiclient_cert_url)) {
- $platform_apiclient_cert = file_get_contents($platform_apiclient_cert_url);
- } else {
- if (!empty($platform_apiclient_cert)) {
- $platform_apiclient_cert_url = WechatConfigForm::handlePemFile($platform_apiclient_cert);
- }
- }
- if (!empty($platform_apiclient_key_url)) {
- $platform_apiclient_key = file_get_contents($platform_apiclient_key_url);
- } else {
- if (!empty($platform_apiclient_key)) {
- $platform_apiclient_key_url = WechatConfigForm::handlePemFile($platform_apiclient_key);
- }
- }
- Option::set([
- 'platform_appid',
- 'platform_mch_id',
- 'platform_key',
- 'platform_apiclient_cert',
- 'platform_apiclient_key',
- 'platform_apiclient_cert_url',
- 'platform_apiclient_key_url',
- 'platform_pay_key',
- 'platform_app_appid',
- 'platform_gh_id'
- ], [
- $platform_appid,
- $platform_mch_id,
- $platform_key,
- $platform_apiclient_cert,
- $platform_apiclient_key,
- $platform_apiclient_cert_url,
- $platform_apiclient_key_url,
- $platform_pay_key,
- $platform_app_appid,
- $platform_gh_id
- ], 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $keys = [
- 'platform_appid',
- 'platform_mch_id',
- 'platform_key',
- 'platform_apiclient_cert',
- 'platform_apiclient_key',
- 'platform_apiclient_cert_url',
- 'platform_apiclient_key_url',
- 'platform_pay_key',
- 'platform_app_appid',
- 'platform_gh_id'
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'platform_appid' => '',
- 'platform_mch_id' => '',
- 'platform_key' => ' ',
- 'platform_apiclient_cert' => '',
- 'platform_apiclient_key' => '',
- 'platform_apiclient_cert_url' => '',
- 'platform_apiclient_key_url' => '',
- 'platform_pay_key' => '',
- 'platform_app_appid' => '',
- 'platform_gh_id' => ''
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- if (empty($arr['platform_apiclient_cert_url']) && !empty($arr['platform_apiclient_cert'])) {
- $arr['platform_apiclient_cert_url'] = WechatConfigForm::handlePemFile($arr['platform_apiclient_cert']);
- }
- if (empty($arr['platform_apiclient_key_url']) && !empty($arr['platform_apiclient_key'])) {
- $arr['platform_apiclient_key_url'] = WechatConfigForm::handlePemFile($arr['platform_apiclient_key']);
- }
- $data = $arr;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置商家小程序配置
- *
- * @return void
- */
- public function actionWechatPlatformMchSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $platform_mch_is_shenhe = post_params('platform_mch_is_shenhe', false);
- $platform_mch_appid = post_params('platform_mch_appid', '');
- $platform_mch_key = post_params('platform_mch_key', '');
- $platform_mch_id = post_params('platform_mch_id', '');
- $platform_apiclient_cert = post_params('platform_apiclient_cert', '');
- $platform_apiclient_key = post_params('platform_apiclient_key', '');
- $platform_apiclient_cert_url = post_params('platform_apiclient_cert_url', '');
- $platform_apiclient_key_url = post_params('platform_apiclient_key_url', '');
- $platform_pay_key = post_params('platform_pay_key', '');
- $platform_mch_api_key = post_params('platform_mch_api_key', '');
- $platform_mch_api_serial_no = post_params('platform_mch_api_serial_no', '');
- $platform_mch_public_key = post_params('platform_mch_public_key', '');
- $platform_mch_public_key_id = post_params('platform_mch_public_key_id', '');
- if (!empty($platform_apiclient_cert_url)) {
- $platform_apiclient_cert = file_get_contents($platform_apiclient_cert_url);
- } else {
- if (!empty($platform_apiclient_cert)) {
- $platform_apiclient_cert_url = WechatConfigForm::handlePemFile($platform_apiclient_cert);
- }
- }
- if (!empty($platform_apiclient_key_url)) {
- $platform_apiclient_key = file_get_contents($platform_apiclient_key_url);
- } else {
- if (!empty($platform_apiclient_key)) {
- $platform_apiclient_key_url = WechatConfigForm::handlePemFile($platform_apiclient_key);
- }
- }
- Option::set([
- 'platform_mch_is_shenhe',
- 'platform_mch_appid',
- 'platform_mch_key',
- 'platform_mch_id',
- 'platform_apiclient_cert',
- 'platform_apiclient_key',
- 'platform_apiclient_cert_url',
- 'platform_apiclient_key_url',
- 'platform_mch_public_key',
- 'platform_mch_public_key_id',
- 'platform_pay_key',
- 'platform_mch_api_key',
- 'platform_mch_api_serial_no'
- ], [
- $platform_mch_is_shenhe,
- $platform_mch_appid,
- $platform_mch_key,
- $platform_mch_id,
- $platform_apiclient_cert,
- $platform_apiclient_key,
- $platform_apiclient_cert_url,
- $platform_apiclient_key_url,
- $platform_mch_public_key,
- $platform_mch_public_key_id,
- $platform_pay_key,
- $platform_mch_api_key,
- $platform_mch_api_serial_no
- ], 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $keys = [
- 'platform_mch_is_shenhe',
- 'platform_mch_appid',
- 'platform_mch_key',
- 'platform_mch_id',
- 'platform_apiclient_cert',
- 'platform_apiclient_key',
- 'platform_apiclient_cert_url',
- 'platform_apiclient_key_url',
- 'platform_mch_public_key',
- 'platform_mch_public_key_id',
- 'platform_pay_key',
- 'platform_mch_api_key',
- 'platform_mch_api_serial_no'
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'platform_mch_is_shenhe' => false,
- 'platform_mch_appid' => '',
- 'platform_mch_key' => '',
- 'platform_mch_id' => '',
- 'platform_apiclient_cert' => '',
- 'platform_apiclient_key' => '',
- 'platform_apiclient_cert_url' => '',
- 'platform_apiclient_key_url' => '',
- 'platform_mch_public_key'=>"",
- 'platform_mch_public_key_id'=>"",
- 'platform_pay_key' => '',
- 'platform_mch_api_key' => '',
- 'platform_mch_api_serial_no' => ''
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- if (empty($arr['platform_apiclient_cert_url']) && !empty($arr['platform_apiclient_cert'])) {
- $arr['platform_apiclient_cert_url'] = WechatConfigForm::handlePemFile($arr['platform_apiclient_cert']);
- }
- if (empty($arr['platform_apiclient_key_url']) && !empty($arr['platform_apiclient_key'])) {
- $arr['platform_apiclient_key_url'] = WechatConfigForm::handlePemFile($arr['platform_apiclient_key']);
- }
- $data = $arr;
- }
- if ($data['platform_mch_is_shenhe'] === '') {
- $data['platform_mch_is_shenhe'] = false;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置联盟服务协议隐私政策配置
- *
- */
- public function actionAllianceArticle()
- {
- if (Yii::$app->request->getIsPost()) {
- $alliance_service_article = post_params('alliance_service_article', '');
- $alliance_privacy_article = post_params('alliance_privacy_article', '');
- $alliance_about_us_article = post_params('alliance_about_us_article', '');
- $data = [
- [
- 'name' => '服务协议',
- 'type' => AboutArticle::TYPE_SERVICE,
- 'desc' => $alliance_service_article
- ],
- [
- 'name' => '隐私政策',
- 'type' => AboutArticle::TYPE_PRIVACY,
- 'desc' => $alliance_privacy_article
- ],
- [
- 'name' => '关于我们',
- 'type' => AboutArticle::TYPE_ABOUT_US,
- 'desc' => $alliance_about_us_article
- ]
- ];
- foreach ($data as $item) {
- $article = AboutArticle::find()->where(['type' => $item['type'], 'is_delete' => 0, 'store_id' => -1])->one();
- $article = $article ?? new AboutArticle();
- $article->store_id = -1;
- $article->name = $item['name'];
- $article->desc = $item['desc'];
- $article->type = $item['type'];
- $article->save();
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $alliance_service_article = AboutArticle::find()->where(['type' => AboutArticle::TYPE_SERVICE, 'is_delete' => 0])
- ->select(['desc'])->asArray()->one();
- $alliance_privacy_article = AboutArticle::find()->where(['type' => AboutArticle::TYPE_PRIVACY, 'is_delete' => 0])
- ->select(['desc'])->asArray()->one();
- $alliance_about_us_article = AboutArticle::find()->where(['type' => AboutArticle::TYPE_ABOUT_US, 'is_delete' => 0])
- ->select(['desc'])->asArray()->one();
- $data = [
- 'alliance_service_article' => $alliance_service_article['desc'] ?? '',
- 'alliance_privacy_article' => $alliance_privacy_article['desc'] ?? '',
- 'alliance_about_us_article' => $alliance_about_us_article['desc'] ?? '',
- ];
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置支付宝第三方信息
- *
- * @return void
- */
- public function actionAliThirdSetting()
- {
- $ali_plugin_goodsDetail_key = OptionSetting::ALI_MINI_PLUGIN_goodsDetail;
- if (Yii::$app->request->getIsPost()) {
- $ali_template_token = post_params('ali_template_token', '');//消息验证token
- $ali_template_aes = post_params('ali_template_aes','');//加密key
- $ali_template_appid = post_params('ali_template_appid','');//模板小程序appid
- $ali_template_store_id = post_params('ali_template_store_id','');//模板默认店铺id
- $ali_template_mini_id = post_params('ali_template_mini_id','');//模板默认小程序id
- $ali_plugin_goodsDetail = post_params($ali_plugin_goodsDetail_key, 1);
- Option::set([
- 'ali_template_store_id',
- 'ali_template_mini_id',
- 'ali_template_token',
- 'ali_template_aes',
- 'ali_template_appid',
- $ali_plugin_goodsDetail_key,
- ], [
- $ali_template_store_id,
- $ali_template_mini_id,
- $ali_template_token,
- $ali_template_aes,
- $ali_template_appid,
- $ali_plugin_goodsDetail,
- ], 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $keys = [
- 'ali_template_store_id',
- 'ali_template_mini_id',
- 'ali_template_token',
- 'ali_template_aes',
- 'ali_template_appid'
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'ali_template_store_id'=>'',
- 'ali_template_mini_id'=>'',
- 'ali_template_token'=>'',
- 'ali_template_aes'=>'',
- 'ali_template_appid'=>'',
- $ali_plugin_goodsDetail_key => 1,
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- $data = $arr;
- $ali_plugin_goodsDetail = Option::get($ali_plugin_goodsDetail_key, 0, 'saas', 1)['value'];
- $data[$ali_plugin_goodsDetail_key] = $ali_plugin_goodsDetail;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置微信第三方信息
- *
- * @return void
- */
- public function actionWechatThirdSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $platform_token = post_params('platform_token', '');//消息验证token
- $platform_encodingAesKey = post_params('platform_encodingAesKey','');//加密key
- $platform_phone = post_params('platform_phone','');//平台手机号
- $platform_third_appid = post_params("platform_third_appid","");//三方平台Appid
- $platform_third_secret = post_params("platform_third_secret","");//三方平台AppSecret
- $platform_template_id = post_params("platform_template_id","");//三方平台模板ID
- $platform_wechat_third_appid = post_params('platform_wechat_third_appid','');//三方绑定的小程序appid
- $platform_wechat_b2b_store_min_rate = post_params('platform_wechat_b2b_store_min_rate','');//店铺内b2b优惠费率最低值
- $platform_wechat_fuwu_appid = post_params('platform_wechat_fuwu_appid','wx2455c3e38caf34a0');//服务市场企业appid
- $platform_wechat_fuwu_secret = post_params('platform_wechat_fuwu_secret','483b2c2357868b91825a415bbba45cc7');//服务市场企业secret
- $platform_wechat_fuwu_serviceId = post_params('platform_wechat_fuwu_serviceId','');//三方绑定的视频号小店serviceId,多个用逗号隔开
- $platform_wechat_fuwu_help_qrcode = post_params('platform_wechat_fuwu_help_qrcode','');//视频号小店指南-二维码
- $platform_wechat_fuwu_help_tel = post_params('platform_wechat_fuwu_help_tel','');//视频号小店指南-电话
- $platform_wechat_fuwu_help_link = post_params('platform_wechat_fuwu_help_link','');//视频号小店指南-文档链接
- $local_sym_sn = post_params('local_sym_sn','');//对称密钥编号
- $local_sym_key = post_params('local_sym_key','');//对称密钥密钥明文
- $rsa_sn = post_params('rsa_sn','');//非对称密钥编号
- $rsa_private_key = post_params('rsa_private_key','');//非对称密钥私玥
- Option::set([
- 'platform_token',
- 'platform_encodingAesKey',
- 'platform_phone',
- "platform_third_appid",
- "platform_third_secret",
- "platform_template_id",
- 'platform_wechat_third_appid',
- 'platform_wechat_b2b_store_min_rate',
- 'platform_wechat_fuwu_appid',
- 'platform_wechat_fuwu_secret',
- 'platform_wechat_fuwu_serviceId',
- 'platform_wechat_fuwu_help_qrcode',
- 'platform_wechat_fuwu_help_tel',
- 'platform_wechat_fuwu_help_link',
- ], [
- $platform_token,
- $platform_encodingAesKey,
- $platform_phone,
- $platform_third_appid,
- $platform_third_secret,
- $platform_template_id,
- $platform_wechat_third_appid,
- $platform_wechat_b2b_store_min_rate,
- $platform_wechat_fuwu_appid,
- $platform_wechat_fuwu_secret,
- $platform_wechat_fuwu_serviceId,
- $platform_wechat_fuwu_help_qrcode,
- $platform_wechat_fuwu_help_tel,
- $platform_wechat_fuwu_help_link,
- ], 0, 'saas');
- Option::set([
- 'local_sym_sn',
- 'local_sym_key',
- 'rsa_sn',
- 'rsa_private_key',
- ], [
- $local_sym_sn,
- $local_sym_key,
- $rsa_sn,
- $rsa_private_key
- ], 0, 'delivery');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $keys = [
- 'platform_token',
- 'platform_encodingAesKey',
- 'platform_phone',
- 'platform_third_appid',
- 'platform_third_secret',
- 'platform_template_id',
- 'platform_wechat_fuwu_appid',
- 'platform_wechat_fuwu_secret',
- 'platform_wechat_fuwu_serviceId',
- 'platform_wechat_third_appid',
- 'platform_wechat_b2b_store_min_rate',
- 'platform_wechat_fuwu_help_qrcode',
- 'platform_wechat_fuwu_help_tel',
- 'platform_wechat_fuwu_help_link',
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'platform_token'=>'',
- 'platform_encodingAesKey'=>'',
- 'platform_phone'=>'',
- 'platform_third_appid'=>"",
- 'platform_third_secret'=>"",
- 'platform_template_id'=>"",
- 'platform_wechat_fuwu_appid'=>"",
- 'platform_wechat_fuwu_secret'=>"",
- 'platform_wechat_fuwu_serviceId'=>"",
- 'platform_wechat_third_appid' => '',
- 'platform_wechat_b2b_store_min_rate' => '',
- 'platform_wechat_fuwu_help_qrcode' => '',
- 'platform_wechat_fuwu_help_tel' => '',
- 'platform_wechat_fuwu_help_link' => '',
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- $data = $arr;
- }
- $keys = [
- 'local_sym_sn',
- 'local_sym_key',
- 'rsa_sn',
- 'rsa_private_key'
- ];
- $delivery_data = Option::get($keys, 0, 'delivery');
- if (empty($data)) {
- $delivery_data = [
- 'local_sym_sn' => '',
- 'local_sym_key' => '',
- 'rsa_sn' => '',
- 'rsa_private_key' => '',
- ];
- } else {
- $arr = [];
- foreach ($delivery_data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- $delivery_data = $arr;
- }
- $data = array_merge($data, $delivery_data);
- //服务url
- $data['platform_wechat_fuwu_serviceUrl'] = \Yii::$app->request->hostInfo . "/index.php/wechat/fuwu-buyer-login";
- // if($data['platform_wechat_fuwu_serviceId']){
- $data['platform_wechat_fuwu_serviceId_qr'] = (new \app\modules\admin\models\WechatThirdForm())->serviceQrcode($data['platform_wechat_fuwu_serviceId']);
- // }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置代理中心配置
- */
- public function actionAgencyConfig(){
- if (Yii::$app->request->getIsPost()) {
- $params = [
- 'lowerLevelShop' => get_params('lowerLevelShop', ""),
- 'lowerLevelShopIcon' => get_params('lowerLevelShopIcon', ""),
- 'renewOrder' => get_params('renewOrder', ""),
- 'renewOrderIcon' => get_params('renewOrderIcon', ""),
- // 'Withdrawal' => get_params('Withdrawal', ""),
- // 'WithdrawalIcon' => get_params('WithdrawalIcon', ""),
- // 'commissionDetail' => get_params('commissionDetail', ""),
- // 'commissionDetailIcon' => get_params('commissionDetailIcon', ""),
- // 'WithdrawalLog' => get_params('WithdrawalLog', ""),
- // 'WithdrawalLogIcon' => get_params('WithdrawalLogIcon', ""),
- 'shopOrder' => get_params('shopOrder', ""),
- 'shopOrderIcon' => get_params('shopOrderIcon', "")
- ];
- Option::set('agency_config', json_encode($params), 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- }else{
- $option = Option::get('agency_config', 0, 'saas');
- $option = json_decode($option['value'], true);
- $data = [
- 'lowerLevelShop' => $option['lowerLevelShop'] ?: "",
- 'lowerLevelShopIcon' => $option['lowerLevelShopIcon'] ?: "",
- 'renewOrder' => $option['renewOrder'] ?: "",
- 'renewOrderIcon' => $option['renewOrderIcon'] ?: "",
- // 'Withdrawal' => $option['Withdrawal'] ?: "",
- // 'WithdrawalIcon' => $option['WithdrawalIcon'] ?: "",
- // 'commissionDetail' => $option['commissionDetail'] ?: "",
- // 'commissionDetailIcon'=> $option['commissionDetailIcon'] ?: "",
- // 'WithdrawalLog' => $option['WithdrawalLog'] ?: "",
- // 'WithdrawalLogIcon' => $option['WithdrawalLogIcon'] ?: "",
- 'shopOrder' => $option['shopOrder'] ?: "",
- 'shopOrderIcon' => $option['shopOrderIcon'] ?: ""
- ];
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置产品代理中心配置
- */
- public function actionGoodsAgentPriceConfig(){
- try {
- if (Yii::$app->request->getIsPost()) {
- $params = [
- 'goods_agent_percent' => post_params('goods_agent_percent', "0.00"),
- 'goods_agent_install_percent' => post_params('goods_agent_install_percent', ""),
- ];
- Option::set('goods_agent_price_config', json_encode($params), 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- }else{
- $option = Option::get('goods_agent_price_config', 0, 'saas');
- if ($option['value']) {
- $option = json_decode($option['value'], true);
- }
- $data = [
- 'goods_agent_percent' => $option['goods_agent_percent'] ?: "0.00",
- 'goods_agent_install_percent' => $option['goods_agent_install_percent'] ?: "0.00",
- ];
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- } catch (\Exception $e) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $e->getMessage(),
- ]);
- }
- }
- /**
- * 设置代理中心配置
- */
- public function actionAgencyPriceConfig(){
- if (Yii::$app->request->getIsPost()) {
- $params = [
- 'supplier_province_percent' => post_params('supplier_province_percent', ""),
- 'supplier_city_percent' => post_params('supplier_city_percent', ""),
- 'supplier_district_percent' => post_params('supplier_district_percent', ""),
- 'model_type' => post_params('model_type', 0),//运营模式
- 'province_percent' => post_params('province_percent', ""),
- 'city_percent' => post_params('city_percent', ""),
- 'district_percent' => post_params('district_percent', ""),
- ];
- Option::set('agency_price_config', json_encode($params), 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- }else{
- $option = Option::get('agency_price_config', 0, 'saas');
- if ($option['value']) {
- $option = json_decode($option['value'], true);
- }
- $data = [
- 'province_percent' => $option['province_percent'] ?: "",
- 'city_percent' => $option['city_percent'] ?: "",
- 'district_percent' => $option['district_percent'] ?: "",
- 'supplier_province_percent' => $option['supplier_province_percent'] ?: "",
- 'supplier_city_percent' => $option['supplier_city_percent'] ?: "",
- 'supplier_district_percent' => $option['supplier_district_percent'] ?: "",
- 'model_type' => $option['model_type'] ?: 0
- ];
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置推广代理佣金配置
- */
- public function actionBdAgencyPriceConfig(){
- $option = Option::get('bd_agency_price_config', 0, 'saas')['value'];
- if ($option) {
- $option = json_decode($option, true);
- }
- if (Yii::$app->request->getIsPost()) {
- $option['bd_agent_percent'] = post_params('bd_agent_percent', "");
- $option['supplier_bd_agent_percent'] = post_params('supplier_bd_agent_percent', "");
- Option::set('bd_agency_price_config', json_encode($option), 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- }else{
- $data = [
- 'bd_agent_percent' => $option['bd_agent_percent'] ?: 0,
- 'supplier_bd_agent_percent' => $option['supplier_bd_agent_percent'] ?: 0,
- ];
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- /**
- * 设置商户分销
- *
- * @return void
- */
- public function actionStoreShareSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $params = [
- 'level' => post_params('level', 0),
- 'is_rebate' => post_params('is_rebate', 0),
- 'price_type' => post_params('price_type', 0),
- 'level_one' => post_params('level_one', 0),
- 'level_two' => post_params('level_two', 0),
- 'level_three' => post_params('level_three', 0),
- ];
- Option::set('store_share', json_encode($params), 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $data = Option::get('store_share', 0, 'saas');
- if (empty($data['value'])) {
- $data = [
- 'level' => 0,
- 'is_rebate' => 0,
- 'price_type' => 0,
- 'level_one' => 0,
- 'level_two' => 0,
- 'level_three' => 0,
- ];
- } else {
- $data = json_decode($data['value'], true);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- public function actionProfitReceiver()
- {
- $form = new ProfitReceiverForm();
- if (Yii::$app->request->getIsPost()) {
- $form->attributes = post_params();
- $form->ratio = post_params('ratio');
- $form->max_amount = post_params('max_amount');
- return $this->asJson($form->save());
- }
- $form->search_key = get_params('search_key');
- return $this->asJson($form->search());
- }
- public function actionDeleteReceiver()
- {
- $res = ProfitSharingReceiver::find()->where(['store_id' => get_store_id(), 'id' => post_params('id'), 'is_delete' => 0])->one();
- if (!$res) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '未找到该记录'
- ]);
- }
- $res->is_delete = 1;
- if ($res->save()) {
- return $this->asJson([
- 'code' => 0,
- 'msg' => '删除成功'
- ]);
- }
- return $this->asJson([
- 'code' => 1,
- 'msg' => $res->errors[0]
- ]);
- }
- /**
- * 分帐记录情况
- * @return \yii\web\Response
- */
- public function actionShareProfitRecord()
- {
- $form = new ShareProfitListForm();
- $form->store_id = get_store_id();
- $form->attributes = get_params();
- return $this->asJson($form->search());
- }
- /**
- * 财务列表
- * @return \yii\web\Response
- */
- public function actionFinanciaList()
- {
- $params = get_params();
- if (isset($params['isExprot'])) {
- $params['isExport'] = 1;
- }
- $form = new ShareFinancialListForm();
- $form->attributes = $params;
- return $this->asJson($form->financialList());
- }
- /**
- * 订单列表(成本价)
- */
- public function actionOrderCostProfitList() {
- $form = new CostProfitListForm();
- $form->store_id = get_store_id();
- $form->attributes = get_params();
- return $this->asJson($form->search());
- }
- /**
- * 联盟佣金平台提现审核列表
- * @return \yii\web\Response
- */
- public function actionProfitCash()
- {
- $form = new PlatformProfitCashForm();
- $form->attributes = get_params();
- return $this->asJson($form->search());
- }
- /**
- * 审核
- * @return \yii\web\Response
- */
- public function actionProfitCashAudit()
- {
- $form = new PlatformProfitCashForm();
- $form->attributes = post_params();
- return $this->asJson($form->audit());
- }
- /**
- * 提现记录删除
- * @return \yii\web\Response
- */
- public function actionProfitCashDel()
- {
- $form = new PlatformProfitCashForm();
- $form->attributes = post_params();
- return $this->asJson($form->del());
- }
- public function actionSmsSetting()
- {
- $default = [
- 'id' => '',
- 'secret' => '',
- 'template' => '',
- ];
- if (Yii::$app->request->getIsPost()) {
- $content = post_params('content', $default);
- Option::set('sms', json_encode($content), 0, 'saas');
- $SmsSetting = SmsSetting::findOne(['store_id' => -1]) ?: new SmsSetting();
- $SmsSetting->AccessKeyId = $content['id'];
- $SmsSetting->AccessKeySecret = $content['secret'];
- $SmsSetting->sign = $content['template'];
- $SmsSetting->store_id = -1;
- $SmsSetting->created_at = time();
- $SmsSetting->save();
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $content = Option::get('sms', 0, 'saas', json_encode($default));
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => json_decode($content['value']),
- ]);
- }
- }
- /**
- * saas上传设置
- */
- public function actionUploadConfig()
- {
- $model = UploadConfig::findOne([
- 'store_id' => 0,
- 'is_delete' => 0,
- ]);
- if (!$model) {
- $model = new UploadConfig();
- }
- $mho = Option::get(OptionSetting::MCH_HIDE_OSS, 0, 'saas', '0')['value'];
- $runOverDefault = [
- 'max_picture' => 10,
- 'max_file' => 10,
- 'over_picture' => 0,
- 'over_file' => 0
- ];
- if (\Yii::$app->request->isPost) {
- $mho = post_params('mch_hide_oss', 0);
- Option::set(OptionSetting::MCH_HIDE_OSS, $mho, 0, 'saas');
- $runOver = \post_params('runOver', $runOverDefault);
- if (!isset($runOver['max_file'])) {
- $runOver['max_file'] = $runOver['max_picture'];
- }
- if (!isset($runOver['over_file'])) {
- $runOver['over_file'] = $runOver['over_picture'];
- }
- Option::set(OptionSetting::PLATFORM_UPLOAD_LIMIT, \json_encode($runOver), 0, 'saas');
- $form = new CommonUpload();
- $form->attributes = post_params();
- $form->model = $model;
- $form->store_id = 0;
- return $this->asJson($form->save());
- } else {
- $model->aliyun = json_decode($model->aliyun, true);
- $model->qcloud = json_decode($model->qcloud, true);
- $model->qiniu = json_decode($model->qiniu, true);
- $model->storage_type = !empty($model->storage_type) ? $model->storage_type : 'local';
- $runOver = Option::get(OptionSetting::PLATFORM_UPLOAD_LIMIT, 0, 'saas', \json_encode($runOverDefault))['value'];
- $runOver = \json_decode($runOver, true);
- if (!isset($runOver['max_file'])) {
- $runOver['max_file'] = $runOver['max_picture'];
- }
- if (!isset($runOver['over_file'])) {
- $runOver['over_file'] = $runOver['over_picture'];
- }
- return $this->asJson([
- 'code' => 0,
- 'data' => $model,
- 'mch_hide_oss' => $mho,
- 'runOver' => $runOver,
- ]);
- }
- }
- /**
- * 平台抖音小程序配置
- *
- */
- public function actionBytedanceSetting()
- {
- if (Yii::$app->request->getIsPost()) {
- $platform_appid = post_params('bytedance_platform_appid', '');
- $platform_salt = post_params('bytedance_platform_salt', '');
- $platform_token = post_params('bytedance_platform_token', '');
- $platform_mch_id = post_params('bytedance_platform_mch_id', '');
- $platform_key = post_params('bytedance_platform_key', '');
- $platform_apiclient_cert = post_params('bytedance_platform_apiclient_cert', '');
- $platform_apiclient_key = post_params('bytedance_platform_apiclient_key', '');
- Option::set([
- 'bytedance_platform_appid',
- 'bytedance_platform_mch_id',
- 'bytedance_platform_key',
- 'bytedance_platform_apiclient_cert',
- 'bytedance_platform_apiclient_key',
- 'bytedance_platform_salt',
- 'bytedance_platform_token',
- ], [
- $platform_appid,
- $platform_mch_id,
- $platform_key,
- $platform_apiclient_cert,
- $platform_apiclient_key,
- $platform_salt,
- $platform_token
- ], 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $keys = [
- 'bytedance_platform_appid',
- 'bytedance_platform_mch_id',
- 'bytedance_platform_key',
- 'bytedance_platform_apiclient_cert',
- 'bytedance_platform_apiclient_key',
- 'bytedance_platform_salt',
- 'bytedance_platform_token'
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'bytedance_platform_appid' => '',
- 'bytedance_platform_mch_id' => '',
- 'bytedance_platform_key' => '',
- 'bytedance_platform_apiclient_cert' => '',
- 'bytedance_platform_apiclient_key' => '',
- 'bytedance_platform_salt' => '',
- 'bytedance_platform_token' => ''
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- $data = $arr;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- }
- public function actionSalesman() {
- $admin = get_admin();
- $name = get_params('name');
- $mobile = get_params('mobile');
- $status = get_params('status', -1);
- if (!in_array($status, [-1, 0, 1])) {
- $status = -1;
- }
- // $query = Store::find()->alias('s')->leftJoin(['ss' => Salesman::tableName()], 's.salesman_id = ss.id')
- // ->leftJoin(['su' => SaasUser::tableName()], 'su.id=ss.saas_user_id')
- // ->where(['ss.is_delete' => 0])
- // ->where(['<>', 's.salesman_id', 0])
- // ->select('ss.id,ss.status,su.name,su.avatar,ss.created_at, su.mobile, s.name as store_name, s.logo as store_logo')->orderBy('s.id desc');
- $query = Salesman::find()->alias('s')
- ->leftJoin(['su' => SaasUser::tableName()], 'su.id=s.saas_user_id')
- ->leftJoin(['a' => Admin::tableName()], 'a.id = s.admin_id')
- ->where(['s.is_delete' => 0, 'a.type' => Admin::ADMIN_TYPE_BD_AGENT])
- ->select('s.id,s.status,su.name,su.avatar,s.created_at,su.mobile,a.name as admin_name')
- ->orderBy('s.created_at desc');
- if ($admin->username != 'admin') {
- $query->andWhere(['s.admin_id' => $admin->id]);
- }
- if ($name) {
- $query->andWhere(['like', 'su.name', $name]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'su.mobile', $mobile]);
- }
- if ($status >= 0) {
- $query->andWhere(['s.status' => $status]);
- }
- $list = pagination_make($query);
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- 'admin' => $admin
- ]
- ]);
- }
- // 修改业务员状态
- public function actionSalesmanStatus()
- {
- $id = post_params('id');
- $status = post_params('status');
- if (!in_array($status, [0, 1])) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => 'status参数值只能是0或1',
- ]);
- }
- $salesman = Salesman::findOne($id);
- if (!$salesman) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '业务员不存在',
- ]);
- }
- $salesman->status = $status;
- if (!$salesman->save()) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $salesman->errors[0],
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '操作成功',
- ]);
- }
- public function actionSalesmanDel() {
- $id = post_params('id');
- $salesman = Salesman::findOne($id);
- if (!$salesman) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '业务员不存在',
- ]);
- }
- $salesman->is_delete = 1;
- if (!$salesman->save()) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $salesman->errors[0],
- ]);
- }
- SaasUser::updateAll(['is_salesman' => 0], ['id' => $salesman->saas_user_id]);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '删除成功',
- ]);
- }
- public function actionSalesmanAdd() {
- $admin = get_admin();
- $admin_id = post_params('admin_id');
- $saas_user_id = post_params('saas_user_id');
- $status = post_params('status', 1);
- if (!$saas_user_id || !in_array($status, [0, 1])) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数有误',
- ]);
- }
- $salesman = Salesman::findOne(['is_delete' => 0, 'saas_user_id' => $saas_user_id]);
- if ($salesman) {
- $admin_ = Admin::findOne(['id' => $salesman->admin_id, 'is_delete' => 0, 'type' => Admin::ADMIN_TYPE_BD_AGENT]);
- if ($admin_) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '业务员已存在',
- ]);
- }
- $salesman->is_delete = 1;
- $salesman->save();
- }
- $salesman = new Salesman();
- if ($admin->username == 'admin' && $admin_id) {
- $salesman->admin_id = $admin_id;
- } else {
- $salesman->admin_id = $admin->id;
- }
- $salesman->saas_user_id = $saas_user_id;
- $salesman->status = $status;
- if (!$salesman->save()) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $salesman->errors[0],
- ]);
- }
- SaasUser::updateAll(['is_salesman' => 1], ['id' => $saas_user_id]);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '添加成功',
- ]);
- }
- public function actionOtherInfo() {
- $store_apply_banner = Option::get('store_apply_banner', 0, 'saas', '')['value'];
- $admin_copyright = Option::get('store_apply_agreement', 0, 'saas', '')['value'];
- $store_apply_audit = Option::get('store_apply_audit', 0, 'saas', '0')['value'];
- $store_apply_free = Option::get('store_apply_free', 0, 'saas', '0')['value'];
- $store_apply_free_days = Option::get('store_apply_free_days', 0, 'saas', 5)['value'];
- $store_apply_buy_type = Option::get('store_apply_buy_type', 0, 'saas', 'free')['value'];//free/once/renew
- $store_apply_buy_money = Option::get('store_apply_buy_money', 0, 'saas', 0)['value'];
- $admin_profit = Option::get('admin_profit', 0, 'saas', 0)['value'];
- $store_apply_renew = Option::get('store_apply_renew', 0, 'saas', 'sys')['value']; //sys/custom
- $sysPriceList = StorePrice::findOne(['is_delete' => 0, 'is_sys' => 1]);
- if (!$sysPriceList) {
- $this->handleSysPriceList();
- }
- $priceList = StorePrice::findAll(['is_delete' => 0]);
- return $this->asJson([
- 'code' => 0,
- 'data' => [
- 'store_apply_banner' => $store_apply_banner ? Json::decode($store_apply_banner) : [],
- 'store_apply_agreement' => $admin_copyright,
- 'store_apply_audit' => $store_apply_audit,
- 'store_apply_free' => $store_apply_free,
- 'store_apply_free_days' => $store_apply_free_days,
- 'store_apply_buy_type' => $store_apply_buy_type,
- 'store_apply_buy_money' => $store_apply_buy_money,
- 'store_apply_renew' => $store_apply_renew,
- 'priceList' => $priceList,
- 'admin_profit' => $admin_profit
- ]
- ]);
- }
- public function handleSysPriceList() {
- $sysPriceList = StorePrice::findOne(['is_delete' => 0, 'is_sys' => 1]);
- if (!$sysPriceList) {
- $arr = [
- [
- 'day' => 30,
- 'price' => 0.00,
- 'text' => '1个月'
- ],
- [
- 'day' => 90,
- 'price' => 0.00,
- 'text' => '3个月'
- ],
- [
- 'day' => 365,
- 'price' => 0.00,
- 'text' => '1年'
- ],
- ];
- foreach ($arr as $item) {
- $price_item = StorePrice::findOne(['is_delete' => 0, 'is_sys' => 1, 'days' => $item['day']]);
- if (!$price_item) {
- $price_item = new StorePrice();
- $price_item->days = $item['day'];
- $price_item->price = $item['price'];
- $price_item->name = $item['text'];
- $price_item->discount_name = '';
- $price_item->used = 1;
- $price_item->is_sys = 1;
- $price_item->save();
- }
- }
- }
- }
- public function actionSubmitOtherInfo() {
- // $store_apply_banner = post_params('store_apply_banner', []);
- // $store_apply_agreement = post_params('store_apply_agreement', '');
- // Option::set('store_apply_banner', Json::encode($store_apply_banner), 0, 'saas');
- // Option::set('store_apply_agreement', $store_apply_agreement, 0, 'saas');
- Option::set('store_apply_audit', input_params('store_apply_audit', 0), 0, 'saas');
- Option::set('store_apply_free', input_params('store_apply_free', 0), 0, 'saas');
- Option::set('store_apply_free_days', input_params('store_apply_free_days', 0), 0, 'saas');
- Option::set('store_apply_buy_type', input_params('store_apply_buy_type'), 0, 'saas');
- Option::set('store_apply_buy_money', input_params('store_apply_buy_money', 0), 0, 'saas');
- Option::set('store_apply_renew', input_params('store_apply_renew'), 0, 'saas');
- Option::set('admin_profit', input_params('admin_profit'), 0, 'saas');
- $priceList = input_params('priceList');
- foreach ($priceList as $item) {
- $model = StorePrice::findOne($item['id']);
- $model->name = $item['name'];
- $model->price = $item['price'];
- $model->discount_name = $item['discount_name'];
- $model->used = $item['used'];
- $model->save();
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '更新成功'
- ]);
- }
- public function actionStorePriceAdd() {
- $model = new StorePrice();
- $id = input_params('id');
- if($id){
- $model = StorePrice::findOne($id);
- }
- $model->days = input_params('days');
- $model->name = input_params('name');
- $model->price = input_params('price');
- $model->discount_name = input_params('discount_name');
- $save = $model->save();
- return $this->asJson([
- 'code' => $save ? 0 : 1,
- 'msg' => $save ? '成功' : '失败',
- ]);
- }
- public function actionStorePriceDel() {
- $model = StorePrice::findOne(input_params('id'));
- $model->is_delete = 1;
- $save = $model->save();
- return $this->asJson([
- 'code' => $save ? 0 : 1,
- 'msg' => $save ? '删除成功' : '删除失败',
- ]);
- }
- public function actionGetCloudApplyInfo() {
- $cloud_apply_banner = Option::get('cloud_apply_banner', 0, 'saas', '')['value'];
- $cloud_apply_agreement = Option::get('cloud_apply_agreement', 0, 'saas', '')['value'];
- return $this->asJson([
- 'code' => 0,
- 'data' => [
- 'cloud_apply_banner' => $cloud_apply_banner ? Json::decode($cloud_apply_banner) : [],
- 'cloud_apply_agreement' => $cloud_apply_agreement
- ]
- ]);
- }
- public function actionSubmitCloudApplyInfo() {
- $cloud_apply_banner = post_params('cloud_apply_banner', []);
- $cloud_apply_agreement = post_params('cloud_apply_agreement', '');
- Option::set('cloud_apply_banner', Json::encode($cloud_apply_banner), 0, 'saas');
- Option::set('cloud_apply_agreement', $cloud_apply_agreement, 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '更新成功'
- ]);
- }
- public function actionMerchantList() {
- $name = get_params('name');
- $salesman = get_params('salesman');
- $status = get_params('status');
- $admin = get_admin();
- $query = MerchantInfo::find()->alias('mi')->leftJoin(['su' => SaasUser::tableName()], 'su.id=mi.saas_user_id')
- ->leftJoin(['s' => Store::tableName()], 's.id=mi.store_id')
- ->where(['s.is_delete' => 0, 'mi.is_delete' => 0]);
- if ($name) {
- $query->andWhere(['or', ['like', 'mi.business_info', $name], ['like', 'mi.subject_info', $name]]);
- }
- if ($status != -1) {
- $query->andWhere(['mi.status' => $status]);
- }
- if ($salesman) {
- $query->andWhere(['like', 'su.name', $salesman]);
- }
- // 如果不是超级管理员,就查找业务员的进件列表
- if ($admin->username != 'admin') {
- $saas_user_id_arr = Salesman::find()->where(['admin_id' => $admin->id, 'is_delete' => 0, 'status' => 1])
- ->select('saas_user_id')->column();
- // $saas_user_id = empty($admin->saas_user_id) ? $admin->saas_user_id : -1;
- $query->andWhere(['mi.saas_user_id' => $saas_user_id_arr ?: -1]);
- }
- $query->orderBy('mi.created_at desc, mi.updated_at desc')->select(['mi.*', 'su.name']);
- $list = pagination_make($query);
- foreach ($list['list'] as &$value) {
- $value['store_logo'] = '';
- $value['store_name'] = '';
- if ($value['bind_store_id'] > 0) {
- $store = Store::findOne($value['bind_store_id']);
- if ($store) {
- $value['store_logo'] = $store->logo;
- $value['store_name'] = $store->name;
- }
- }
- if (!empty($value['business_info'])) {
- $business_info = Json::decode($value['business_info']);
- $value['merchant_name'] = $business_info['merchant_shortname'];
- } else {
- $store = Store::findOne($value['bind_store_id']);
- if ($store) {
- $value['merchant_name'] = $store->name;
- } else {
- $value['merchant_name'] = '';
- }
- }
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- /**
- * ocr接口调用参数配置
- * @return \yii\web\Response
- */
- public function actionOcrSetting()
- {
- $default = [
- 'app_secret' => '',
- 'app_key' => '',
- ];
- if (\Yii::$app->request->getIsPost()) {
- $content = post_params('content', $default);
- Option::set('ocr', json_encode($content), 0, 'saas');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- } else {
- $content = Option::get('ocr', 0, 'saas', json_encode($default));
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => json_decode($content['value']),
- ]);
- }
- }
- /**
- * 灵工接口调用参数配置
- * @return \yii\web\Response
- */
- public function actionLgSetting()
- {
- $default = [
- 'app_secret' => '',
- 'app_key' => '',
- ];
- if (\Yii::$app->request->getIsPost()) {
- $content = post_params('content', $default);
- $store = Store::find()->where(['id'=> get_store_id()])->one();
- $store->lg_mch_id = $content['lg_mch_id'];
- $store->lg_project_code = $content['lg_project_code'];
- $store->lg_park_code = $content['lg_park_code'];
- $store->lg_pkey = $content['lg_pkey'];
- $store->lg_key = $content['lg_key'];
- if ($store->save()){
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- }else{
- return $this->asJson([
- 'code' => 1,
- 'msg' => '保存失败',
- ]);
- }
- } else {
- $store = Store::find()->where(['id'=> get_store_id()])->select('lg_mch_id,lg_project_code,lg_park_code,lg_pkey,lg_key')->asArray()->one();
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' =>$store,
- ]);
- }
- }
- /**
- * 云cloud接口调用参数配置
- * @return \yii\web\Response
- */
- public function actionCloudSetting()
- {
- $default = [
- 'name' => '',
- 'pwd' => '',
- 'rate' => '',
- ];
- if (\Yii::$app->request->getIsPost()) {
- $post = post_params();
- $domain = (new OptionSetting)->getCloudDomainName();
- $url = $domain."/user/getToken";
- $data =[];
- $data['name'] = $post['name'];
- $data['pwd'] = $post['pwd'];
- // $response = cloud_post($url,$data);
- // $response = json_decode($response,true);
- // if($response['code'] != 0 || !$response['taken']){
- // return $this->asJson([
- // 'code' => 1,
- // 'msg' => '保存失败',
- // ]);
- // }
- // \Yii::$app->cache->set('cloud_admin_cache_token', $response['taken'], 2 * 24 * 3600);
- // $data['access_token'] = $response['taken'];
- $data['rate'] = isset($post['rate']) ? (float)$post['rate'] : 10;
- $data['time'] = time();
- Option::set('cloud', json_encode($data), 0, 'saas');
- \Yii::$app->cache->delete('cloud_admin_cache_token');
- get_platform_token();
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- ]);
- } else {
- $content = Option::get('cloud', 0, 'saas', json_encode($default));
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => json_decode($content['value']),
- ]);
- }
- }
- // 云仓采购端配置自定义表单
- public function actionCloudCustomForm()
- {
- try {
- $default = [
- 'name' => '',
- 'pwd' => '',
- 'rate' => '',
- 'sale_day' => 0
- ];
- if (\Yii::$app->request->getIsPost()) {
- $post = post_params();
- // $domain = OptionSetting::CLOUD_DOMAIN_NAME;
- // $url = $domain."/user/getToken";
- $data =[];
- $data['name'] = $post['name'];
- $data['pwd'] = $post['pwd'];
- $data['sale_day'] = $post['sale_day'];
- // $response = cloud_post($url,$data);
- // $response = json_decode($response,true);
- // if ($response['code'] != 0 || !$response['taken']) {
- // return $this->asJson([
- // 'code' => 1,
- // 'msg' => '保存失败',
- // ]);
- // }
- // $data['access_token'] = $response['taken'];
- // \Yii::$app->cache->set('cloud_admin_cache_token', $response['taken'], 2 * 24 * 3600);
- $data['rate'] = isset($post['rate']) ? (float)$post['rate'] : 10;
- $data['time'] = time();
- Option::set('cloud', json_encode($data), 0, 'saas');
- $cloud_domain_name = $post['cloud_domain_name'];
- if ($cloud_domain_name) {
- Option::set('cloud_domain_name', $cloud_domain_name, 0, 'cloud');
- }
- $list = post_params('list');
- $supplier_list = post_params('supplier_list');
- if (!$list) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '缺少必要参数'
- ]);
- }
- $cloud_apply_banner = post_params('cloud_apply_banner', []);
- $cloud_supplier_banner = post_params('cloud_supplier_banner', []);
- $cloud_apply_agreement = post_params('cloud_apply_agreement', '');
- $cloud_supplier_apply_agreement = post_params('cloud_supplier_apply_agreement', '');
- $is_supplier_set_price = post_params('is_supplier_set_price', 1);
- Option::set('cloud_apply_banner', Json::encode($cloud_apply_banner), 0, 'saas');
- Option::set('cloud_supplier_banner', Json::encode($cloud_supplier_banner), 0, 'saas');
- Option::set('cloud_apply_agreement', $cloud_apply_agreement, 0, 'saas');
- Option::set('cloud_supplier_apply_agreement', $cloud_supplier_apply_agreement, 0, 'saas');
- Option::set('cloud_custom_form', json_encode($list), 0, 'saas');
- Option::set('supplier_custom_form', json_encode($supplier_list), 0, 'saas');
- Option::set('is_supplier_set_price', $is_supplier_set_price, 0, 'cloud');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- }
- $cloud_apply_banner = Option::get('cloud_apply_banner', 0, 'saas', '')['value'];
- $cloud_supplier_banner = Option::get('cloud_supplier_banner', 0, 'saas', '')['value'];
- $cloud_apply_agreement = Option::get('cloud_apply_agreement', 0, 'saas', '')['value'];
- $cloud_supplier_apply_agreement = Option::get('cloud_supplier_apply_agreement', 0, 'saas', '')['value'];
- $content = Option::get('cloud', 0, 'saas', json_encode($default));
- $list = Option::get('cloud_custom_form', 0, 'saas', json_encode([]));
- $supplier_custom_form = Option::get('supplier_custom_form', 0, 'saas', json_encode([]));
- $cloud_domain_name = Option::get('cloud_domain_name', 0, 'cloud', 'http://yuncang.tianxin100.vip')['value'];
- $is_supplier_set_price = Option::get('is_supplier_set_price', 0, 'cloud', 1)['value'];
- $content = json_decode($content['value'], true);
- $content = array_merge($content, [
- 'cloud_domain_name' => $cloud_domain_name
- ]);
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'list' => json_decode($list['value']),
- 'supplier_custom_form' => json_decode($supplier_custom_form['value']),
- 'cloud_apply_banner' => $cloud_apply_banner ? Json::decode($cloud_apply_banner) : [],
- 'cloud_supplier_banner' => $cloud_supplier_banner ? Json::decode($cloud_supplier_banner) : [],
- 'cloud_apply_agreement' => $cloud_apply_agreement,
- 'cloud_supplier_apply_agreement' => $cloud_supplier_apply_agreement,
- 'is_supplier_set_price' => (int)$is_supplier_set_price,
- 'content' => $content,
- ]
- ]);
- } catch (\Exception $e) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $e->getMessage()
- ]);
- }
- }
- /**
- * 获取信息
- * @return \yii\web\Response
- */
- public function actionOcrInfo() {
- $type = post_params('type');
- if (empty($type) || !in_array($type, OcrApi::$validType)) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '类型参数错误'
- ]);
- }
- $side = post_params('side');
- if (empty($side) && $type == OcrApi::TYPE_ID_CARD) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '身份证参数有误'
- ]);
- }
- $url = post_params('url');
- if (empty($url)) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '图片地址为空'
- ]);
- }
- try {
- $ocr = new OcrApi(true);
- switch ($type) {
- case OcrApi::TYPE_LICENSE:
- $res = $ocr->getBusinessLicense($url);
- break;
- case OcrApi::TYPE_ID_CARD:
- $res = $ocr->getIDCard($url, $side);
- break;
- case OcrApi::TYPE_BANK:
- $res = $ocr->getBankCard($url);
- break;
- }
- if ($res['code'] == 0 && !empty($res['data'])) {
- return $this->asJson($res);
- }
- return $this->asJson([
- 'code' => -1,
- 'msg' => '获取信息失败'
- ]);
- } catch (\Exception $e) {
- return $this->asJson([
- 'code' => -1,
- 'msg' => $e->getMessage()
- ]);
- }
- }
- /**
- * 获取积分赠送规则
- */
- public function actionGetIntegralRules()
- {
- $form = new SaasForm();
- $form->attributes = post_params();
- return $this->asJson($form->getInfo());
- }
- /**
- * @return \yii\web\Response
- * 获取列表
- */
- public function actionGetList()
- {
- $form = new SaasForm();
- $form->attributes = post_params();
- return $this->asJson($form->getRulesList());
- }
- /**
- * 获取商城信息
- */
- public function actionGetStore()
- {
- $form = new SaasForm();
- $form->attributes = post_params();
- return $this->asJson($form->getStoreList());
- }
- /**
- * 修改规则状态
- */
- public function actionSetStatus()
- {
- $form = new SaasForm();
- $form->attributes = post_params();
- return $this->asJson($form->SetStatus());
- }
- /**
- * 店铺分销列表
- * @return \yii\web\Response
- */
- public function actionStoreShareList()
- {
- $store_name = get_params('store_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $status = get_params('status', -1);
- if (!in_array($status, [-1, 0, 1])) {
- $status = -1;
- }
- $query = Store::find()->alias('s')->leftJoin(['a' => Admin::tableName()], 's.admin_id = a.id');
- $query->where(['s.is_delete' => 0]);
- if ($store_name) {
- $query->andWhere(['like', 's.name', $store_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'a.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'a.mobile', $mobile]);
- }
- if ($status > -1) {
- $query->andWhere(['s.store_share_switch' => $status]);
- }
- $query->select('s.id, s.name as store_name, s.logo, a.name as nickname, a.mobile, s.store_share_switch, s.store_share_type, s.store_share_value');
- $list = pagination_make($query);
- $defaultSet = Option::get(OptionSetting::SHARE_STORE_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME, '{}');
- $defaultSet = json_decode($defaultSet['value'], true);
- foreach ($list['list'] as &$item) {
- $amount = SharingReceiver::find()->where([
- 'store_id' => $item['id'],
- 'from' => 0,
- 'is_delete' => 0,
- ])->sum('amount');
- $item['income'] = $amount ?: '0.00';
- $item['expenditure'] = '0.00';
- $item['use_default'] = 0;
- if($item['store_share_switch'] != 0 && $item['store_share_value'] == 0){
- if(!empty($defaultSet['store_share_switch']) && !empty($defaultSet['store_share_value'])){
- $item['store_share_value'] = $defaultSet['store_share_value'];
- $item['use_default'] = 1;
- }
- }
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'defaultSet' => $defaultSet,
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- /**
- * 修改店铺间分销设置
- * @return Response
- * @throws InvalidConfigException
- * @throws StaleObjectException
- * @throws Exception
- */
- public function actionSetIntegralRules()
- {
- $form = new SaasForm();
- $form->attributes = post_params();
- return $this->asJson($form->save());
- }
- /**
- * 修改店铺间分销设置
- * @return Response
- * @throws InvalidConfigException
- * @throws StaleObjectException
- * @throws Exception
- */
- public function actionStoreShareOption()
- {
- $store_id = post_params('store_id');
- $store_share_switch = post_params('store_share_switch');
- $store_share_type = post_params('store_share_type');
- $store_share_value = post_params('store_share_value');
- // $store_recharge_profit = post_params('store_recharge_profit');
- $store_profit_max = post_params('store_profit_max');
- $store_profit_min = post_params('store_profit_min');
- $store_send_min = post_params('store_send_min');
- // $store_send_profit = post_params('store_send_profit');
-
- // Option::set('store_recharge_profit', $store_recharge_profit, 0);
- Option::set('store_profit_max', $store_profit_max, 0);
- Option::set('store_profit_min', $store_profit_min, 0);
- Option::set('store_send_min', $store_send_min, 0);
- // Option::set('store_send_profit', $store_send_profit, 0);
- //默认配置
- if(intval($store_id) === -1){
- $json = json_encode([
- 'store_share_switch' => $store_share_switch,
- 'store_share_type' => $store_share_type,
- 'store_share_value' => $store_share_value,
- 'store_profit_max' => $store_profit_max,
- 'store_profit_min' => $store_profit_min,
- 'store_send_min' => $store_send_min,
- // 'store_send_profit' => $store_send_profit,
- // 'store_recharge_profit' => $store_recharge_profit,
- ]);
- $res = Option::set(OptionSetting::SHARE_STORE_DEFAULT_SETTING, $json, $store_id, OptionSetting::SHARE_GROUP_NAME);
- if(!$res){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '默认配置编辑失败',
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '默认配置编辑成功',
- ]);
- }
- if (empty($store_id)) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '缺少必要参数',
- ]);
- }
- $store = Store::findOne($store_id);
- if (!$store) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '商城未找到',
- ]);
- }
- if ($store_share_switch !== null) {
- if (!in_array($store_share_switch, [0, 1])) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数错误',
- ]);
- }
- $store->store_share_switch = $store_share_switch;
- }
- if ($store_share_type !== null) {
- if (!in_array($store_share_type, [0, 1])) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数错误',
- ]);
- }
- $store->store_share_type = $store_share_type;
- }
- if (isset($store_share_value)) {
- $store->store_share_value = $store_share_value;
- }
- if (!union_share_scale_check($store)) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '保存失败,分销比例超过100%',
- ]);
- }
- if (!$store->save()) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $store->errors[0],
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '编辑成功',
- ]);
- }
- /**
- * 店铺间分销佣金明细
- * @return Response
- * @throws InvalidConfigException
- * @throws Throwable
- * @throws Exception
- */
- public function actionStoreShareLog()
- {
- $store_name = get_params('store_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $status = get_params('status', -1);
- $start_date = get_params('start_date');
- $end_date = get_params('end_date');
- if (!in_array($status, [-1, 0, 1])) {
- $status = -1;
- }
- $query = SharingReceiver::find()->alias('sr')->leftJoin(['s' => Store::tableName()], 'sr.store_id = s.id')
- ->leftJoin(['su' => SaasUser::tableName()], 'sr.saas_id = su.id')
- ->where(['sr.is_delete' => 0, 'sr.from' => SharingReceiver::FROM_STORE_TO_STORE]);
- if ($store_name) {
- $query->andWhere(['like', 's.name', $store_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'su.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'su.mobile', $mobile]);
- }
- if ($status > -1) {
- $query->andWhere(['sr.is_pay' => $status]);
- }
- if ($start_date) {
- $query->andWhere(['>=', 'sr.created_at', strtotime($start_date)]);
- }
- if ($end_date) {
- $query->andWhere(['<=', 'sr.created_at', strtotime($end_date)]);
- }
- $query->select('sr.id, sr.to_store_id, sr.order_no, s.name as store_name, sr.rate, sr.amount, sr.account, sr.is_pay, sr.created_at, sr.err_code_des ,sr.execute_type, sr.updated_at');
- $list = pagination_make($query);
- foreach ($list['list'] as &$item) {
- //未改动前端 只调了数据
- if ($item['to_store_id']) {
- $store = Store::findOne($item['to_store_id']);
- $item['avatar'] = $store->logo ?? '';
- $item['name'] = $store->name ?? '';
- }
- $item['created_at'] = date("Y-m-d H:i", $item['created_at']);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- /**
- * 联盟分销列表
- * @return \yii\web\Response
- */
- public function actionSaasShareList()
- {
- $store_name = get_params('store_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $query = Store::find()->alias('s')->leftJoin(['a' => Admin::tableName()], 's.admin_id = a.id');
- $query->where(['s.is_delete' => 0]);
- if ($store_name) {
- $query->andWhere(['like', 's.name', $store_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'a.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'a.mobile', $mobile]);
- }
- $query->select('s.id, s.name as store_name, s.logo, a.name as nickname, a.mobile, s.share_setting');
- $list = pagination_make($query);
- foreach ($list['list'] as &$item) {
- $amount = SharingReceiver::find()->where([
- 'store_id' => $item['id'],
- 'from' => 1,
- 'is_delete' => 0,
- ])->sum('amount');
- $item['expenditure'] = $amount ?: '0.00';
- if (empty($item['share_setting'])) {
- $item['switch'] = 0;
- $item['price_type'] = 0;
- $item['level_one'] = '0.00';
- $item['level_two'] = '0.00';
- $item['level_three'] = '0.00';
- $item['is_rebate'] = 0;
- } else {
- $option = json_decode($item['share_setting'], true);
- $item['switch'] = $option['level'];
- $item['price_type'] = $option['price_type'];
- $item['level_one'] = $option['level_one'];
- $item['level_two'] = $option['level_two'];
- $item['level_three'] = $option['level_three'];
- $item['is_rebate'] = $option['is_rebate'];
- }
- $item['use_default'] = 0;
- if($item['switch'] != 0 && $item['level_one'] == 0 && $item['level_two'] == 0 && $item['level_three'] == 0){
- $defaultSet = Option::get(OptionSetting::SHARE_SAAS_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME, '{}');
- $defaultSet = json_decode($defaultSet['value'], true);
- if(!empty($defaultSet['level']) &&
- (!empty($defaultSet['level_one']) || !empty($defaultSet['level_two']) || !empty($defaultSet['level_three']))){
- $item['switch'] = $defaultSet['level'];
- $item['price_type'] = $defaultSet['price_type'];
- $item['level_one'] = $defaultSet['level_one'];
- $item['level_two'] = $defaultSet['level_two'];
- $item['level_three'] = $defaultSet['level_three'];
- $item['is_rebate'] = $defaultSet['is_rebate'];
- $item['use_default'] = 1;
- }
- }
- }
- //默认配置
- $defaultSet = Option::get(OptionSetting::SHARE_SAAS_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME, '{}');
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'defaultSet' => json_decode($defaultSet['value']),
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- /**
- * 联盟分销佣金明细
- * @return Response
- * @throws InvalidConfigException
- * @throws Throwable
- * @throws Exception
- */
- public function actionSaasShareLog()
- {
- $store_name = get_params('store_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $status = get_params('status', -1);
- $start_date = get_params('start_date');
- $end_date = get_params('end_date');
- if (!in_array($status, [-1, 0, 1])) {
- $status = -1;
- }
- $query = SharingReceiver::find()->alias('sr')->leftJoin(['s' => Store::tableName()], 'sr.store_id = s.id')
- //->leftJoin(['su' => SaasUser::tableName()], 'sr.user_id = su.id')
- ->leftJoin(['su' => SaasUser::tableName()], 'sr.saas_id = su.id')
- ->where(['sr.is_delete' => 0, 'sr.from' => 1]);
- if ($store_name) {
- $query->andWhere(['like', 's.name', $store_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'su.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'su.mobile', $mobile]);
- }
- if ($status > -1) {
- $query->andWhere(['sr.is_pay' => $status]);
- }
- if ($start_date) {
- $query->andWhere(['>=', 'sr.created_at', strtotime($start_date)]);
- }
- if ($end_date) {
- $query->andWhere(['<=', 'sr.created_at', strtotime($end_date)]);
- }
- $query->select('sr.id, su.avatar, su.name, su.mobile, sr.order_no, s.name as store_name, sr.rate, sr.amount, sr.is_pay, sr.created_at, sr.err_code_des, sr.execute_type, sr.updated_at, sr.remark')->orderBy('sr.created_at desc');
- $list = pagination_make($query);
- foreach ($list['list'] as &$item) {
- if(!$item['avatar'] && $item['id']){
- $userInfo = User::find()->where(['id'=>$item['id'],'is_delete'=>0])->one();
- if(!empty($userInfo) && !empty($userInfo->avatar_url)){
- $item['avatar'] = $userInfo->avatar_url;
- $item['name'] = $userInfo->nickname;
- }
- }
- $item['created_at'] = date("Y-m-d H:i", $item['created_at']);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- /**
- * 供货商推荐人列表
- */
- public function actionSupplierReferralList()
- {
- $supplier_name = get_params('supplier_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $status = get_params('status', -1);
- if (!in_array($status, [-1, 0, 1])) {
- $status = -1;
- }
- $query = SaasSupplierReferral::find()->alias('ssr')
- ->leftJoin(['su' => SaasUser::tableName()], 'ssr.referral_id = su.id')
- ->leftJoin(['s' => Supplier::tableName()], 'ssr.supplier_id = s.id');
- $query->where(['s.is_delete' => 0]);
- if ($supplier_name) {
- $query->andWhere(['like', 's.name', $supplier_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'su.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'su.mobile', $mobile]);
- }
- if ($status > -1) {
- $query->andWhere(['ssr.is_enable' => $status]);
- }
- $query->orderBy('ssr.id DESC');
- $query->select('ssr.id, ssr.supplier_id, ssr.referral_id, ssr.is_enable, s.supplier_name, s.logo as supplier_logo, s.phone as supplier_phone,
- ssr.referral_rebate, su.avatar, su.name as nickname, su.mobile, su.id as user_id
- ');
- $list = pagination_make($query);
- //默认配置
- $defaultSet = Option::get(OptionSetting::SHARE_SAAS_SUPPLIER_REFERRAL_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME, '{}')['value'];
- $defaultSet = json_decode($defaultSet, true);
- foreach ($list['list'] as &$item) {
- $item['amount'] = SaasUserPriceLog::find()->where(['saas_id' => $item['referral_id'], 'amount_type' => SaasUserPriceLog::AMOUNT_TYPE_SUPPLIER_PARENT])->sum('amount') ?: '0.00';
- $item['use_default'] = 0;
- if($item['is_enable'] != 0 && $item['referral_rebate'] == 0){
- if(!empty($defaultSet['is_enable']) && !empty($defaultSet['referral_rebate'])){
- $item['referral_rebate'] = $defaultSet['referral_rebate'];
- $item['use_default'] = 1;
- }
- }
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'defaultSet' => $defaultSet,
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- /**
- * 供货商推荐人新增编辑
- */
- public function actionEditSupplierReferral()
- {
- $id = post_params('id');
- $supplier_id = post_params('supplier_id');
- $is_enable = post_params('is_enable');
- $referral_id = post_params('referral_id');
- $referral_rebate = post_params('referral_rebate', '0.00');
- if (!$id) {
- $has = SaasSupplierReferral::findOne([
- 'supplier_id' => $supplier_id
- ]);
- if($has){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '不能重复添加',
- ]);
- }
- }
- //默认配置
- if(intval($supplier_id) === -1){
- $json = json_encode([
- 'is_enable' => $is_enable,
- 'referral_rebate' => $referral_rebate,
- ]);
- $res = Option::set(OptionSetting::SHARE_SAAS_SUPPLIER_REFERRAL_DEFAULT_SETTING, $json, $supplier_id, OptionSetting::SHARE_GROUP_NAME);
- if(!$res){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '默认配置编辑失败',
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '默认配置编辑成功',
- ]);
- }
- if (!in_array($is_enable, [0, 1])) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数错误',
- ]);
- }
- $supplier = Supplier::findOne($supplier_id);
- if (!$supplier) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '供货商不存在',
- ]);
- }
- if ($id) {
- $item = SaasSupplierReferral::findOne($id);
- if ($is_enable !== null) {
- $item->is_enable = $is_enable;
- }
- if (isset($referral_rebate)) {
- $item->referral_rebate = $referral_rebate;
- }
- $item->save();
- return $this->asJson([
- 'code' => 0,
- 'msg' => '编辑成功',
- ]);
- } else {
- $saasUser = SaasUser::findOne($referral_id);
- if (!$saasUser) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '用户不存在',
- ]);
- }
- $item = new SaasSupplierReferral();
- $item->supplier_id = $supplier_id;
- $item->referral_id = $referral_id;
- $item->referral_rebate = $referral_rebate;
- $item->is_enable = $is_enable;
- $item->save();
- return $this->asJson([
- 'code' => 0,
- 'msg' => '绑定成功',
- ]);
- }
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数错误',
- ]);
- }
- /**
- * 推荐人列表
- * @return Response
- * @throws InvalidConfigException
- * @throws Throwable
- * @throws Exception
- */
- public function actionReferralList()
- {
- $store_name = get_params('store_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $status = get_params('status', -1);
- $query = SaasStoreReferral::find()->alias('ssr')
- ->leftJoin(['su' => SaasUser::tableName()], 'ssr.referral_id = su.id')
- ->leftJoin(['s' => Store::tableName()], 'ssr.store_id = s.id');
- $query->where(['s.is_delete' => 0, 'ssr.type' => 1]);
- if ($store_name) {
- $query->andWhere(['like', 's.name', $store_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'su.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'su.mobile', $mobile]);
- }
- if (isset($status) && in_array($status, [0, 1])) {
- $query->andWhere(['ssr.is_enable' => $status]);
- }
- $query->orderBy('ssr.id DESC');
- $query->select('ssr.id, ssr.store_id, ssr.referral_id, ssr.is_enable, s.name as store_name, s.logo as store_logo, s.contact_tel,
- ssr.referral_rebate, su.avatar, su.name as nickname, su.mobile, su.id as user_id
- ');
- $list = pagination_make($query);
- foreach ($list['list'] as &$item) {
- $item['amount'] = SharingReceiver::find()->where(['is_delete' => 0, 'saas_id' => $item['user_id'], 'from' => SharingReceiver::FROM_NEW_STORE_RECOMMEND])
- ->sum('amount') ?: '0.00';
- $item['use_default'] = 0;
- if($item['is_enable'] != 0 && $item['referral_rebate'] == 0){
- $defaultSet = Option::get(OptionSetting::SHARE_SAAS_REFERRAL_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME, '{}');
- $defaultSet = json_decode($defaultSet['value'], true);
- if(!empty($defaultSet['is_enable']) && !empty($defaultSet['referral_rebate'])){
- $item['referral_rebate'] = $defaultSet['referral_rebate'];
- $item['use_default'] = 1;
- }
- }
- }
- //默认配置
- $defaultSet = Option::get(OptionSetting::SHARE_SAAS_REFERRAL_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME, '{}');
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'defaultSet' => json_decode($defaultSet['value']),
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- /**
- * 推荐人新增编辑
- * @return Response
- * @throws InvalidConfigException
- * @throws StaleObjectException
- * @throws Exception
- * @throws NotSupportedException
- * @throws InvalidArgumentException
- * @throws GlobalException
- */
- public function actionEditReferral()
- {
- $id = post_params('id');
- $store_id = post_params('store_id');
- $is_enable = post_params('is_enable');
- $referral_id = post_params('referral_id');
- $referral_rebate = post_params('referral_rebate', '0.00');
- if (!$id) {
- $has = SaasStoreReferral::findOne([
- 'store_id' => $store_id,
- 'type' => 1
- ]);
- if($has){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '不能重复添加',
- ]);
- }
- }
- //默认配置
- if(intval($store_id) === -1){
- $json = json_encode([
- 'is_enable' => $is_enable,
- 'referral_rebate' => $referral_rebate,
- ]);
- $res = Option::set(OptionSetting::SHARE_SAAS_REFERRAL_DEFAULT_SETTING, $json, $store_id, OptionSetting::SHARE_GROUP_NAME);
- if(!$res){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '默认配置编辑失败',
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '默认配置编辑成功',
- ]);
- }
- if (!in_array($is_enable, [0, 1])) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数错误',
- ]);
- }
- $store = Store::findOne($store_id);
- if (!$store) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '商城不存在',
- ]);
- }
- $scale = union_share_scale($store, true);
- if ($id) {
- $item = SaasStoreReferral::findOne($id);
- if ($is_enable !== null) {
- $item->is_enable = $is_enable;
- }
- if (isset($referral_rebate)) {
- // 检查比例是否超过100%
- $referral = SaasStoreReferral::find()
- ->where(['store_id' => $store->id, 'type' => 1])
- ->andWhere(['<>', 'id', $id])
- ->asArray()
- ->all();
- if (count($referral) > 0) {
- foreach ($referral as $iitem) {
- $scale += $iitem['referral_rebate'];
- }
- }
- $scale += $referral_rebate;
- if ($scale > 100) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '编辑失败,分销比例超过100% 当前累计分销比例:' . $scale .'%',
- ]);
- }
- $item->referral_rebate = $referral_rebate;
- }
- $item->save();
- return $this->asJson([
- 'code' => 0,
- 'msg' => '编辑成功',
- ]);
- } else {
- $saasUser = SaasUser::findOne($referral_id);
- if (!$saasUser) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '用户不存在',
- ]);
- }
- // 检查比例是否超过100%
- $referral = SaasStoreReferral::find()
- ->where(['store_id' => $store->id, 'type' => 1])
- ->asArray()
- ->all();
- if (count($referral) > 0) {
- foreach ($referral as $item) {
- $scale += $item['referral_rebate'];
- }
- }
- $scale += $referral_rebate;
- if ($scale > 100) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '创建失败,分销比例超过100% 当前累计分销比例:' . $scale .'%',
- ]);
- }
- $item = new SaasStoreReferral();
- $item->store_id = $store_id;
- $item->referral_id = $referral_id;
- $item->referral_rebate = $referral_rebate;
- $item->is_enable = $is_enable;
- $item->type = 1;
- $item->save();
- return $this->asJson([
- 'code' => 0,
- 'msg' => '绑定成功',
- ]);
- }
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数错误',
- ]);
- }
- /**
- * 删除绑定推荐人
- * @return Response
- * @throws InvalidConfigException
- * @throws StaleObjectException
- * @throws GlobalException
- * @throws Throwable
- */
- public function actionDeleteReferral()
- {
- $id = post_params('id');
- $item = SaasStoreReferral::findOne($id);
- if (!$item) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '数据不存在',
- ]);
- }
- $item->delete();
- return $this->asJson([
- 'code' => 0,
- 'msg' => '删除成功',
- ]);
- }
- /**
- * 删除绑定推荐人
- * @return Response
- * @throws InvalidConfigException
- * @throws StaleObjectException
- * @throws GlobalException
- * @throws Throwable
- */
- public function actionDeleteSupplierReferral()
- {
- $id = post_params('id');
- $item = SaasSupplierReferral::findOne($id);
- if (!$item) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '数据不存在',
- ]);
- }
- $item->delete();
- return $this->asJson([
- 'code' => 0,
- 'msg' => '删除成功',
- ]);
- }
- /**
- * 联盟推荐人佣金明细
- * @return Response
- * @throws InvalidConfigException
- * @throws Throwable
- * @throws Exception
- */
- public function actionReferralShareLog()
- {
- $store_name = get_params('store_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $status = get_params('status', -1);
- $start_date = get_params('start_date');
- $end_date = get_params('end_date');
- $query = SharingReceiver::find()->alias('sr')->leftJoin(['s' => Store::tableName()], 'sr.store_id = s.id')
- ->leftJoin(['su' => SaasUser::tableName()], 'sr.saas_id = su.id')
- ->where(['sr.is_delete' => 0, 'sr.from' => SharingReceiver::FROM_NEW_STORE_RECOMMEND]);
- if ($store_name) {
- $query->andWhere(['like', 's.name', $store_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'su.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'su.mobile', $mobile]);
- }
- if (isset($status) && in_array($status, [0, 1])) {
- $query->andWhere(['ssr.is_enable' => $status]);
- }
- if ($start_date) {
- $query->andWhere(['>=', 'sr.created_at', strtotime($start_date)]);
- }
- if ($end_date) {
- $query->andWhere(['<=', 'sr.created_at', strtotime($end_date)]);
- }
- $query->select('sr.id, sr.saas_id, sr.user_id, su.avatar, su.name, su.mobile, sr.order_no, s.name as store_name, sr.rate, sr.amount, sr.is_pay, sr.created_at ,sr.err_code_des ,sr.execute_type, sr.updated_at');
- $list = pagination_make($query);
- foreach ($list['list'] as &$item) {
- if(!$item['saas_id']){
- $orderNoHead = substr($item['order_no'], 0, 2);
- if($orderNoHead == 'SC'){
- $order = \app\plugins\scanCodePay\models\Order::findOne(['order_no' => $item['order_no']]);
- }else{
- $order = Order::findOne(['order_no' => $item['order_no']]);
- }
- if($order->is_platform){
- $userInfo = SaasUser::findOne($item['user_id']);
- if(!empty($userInfo) && !empty($userInfo->avatar)){
- $item['avatar'] = $userInfo->avatar;
- $item['name'] = $userInfo->name;
- $item['mobile'] = $userInfo->mobile;
- }
- }else{
- $userInfo = User::findOne($item['user_id']);
- if(!empty($userInfo) && !empty($userInfo->avatar_url)){
- $item['avatar'] = $userInfo->avatar_url;
- $item['name'] = $userInfo->nickname;
- $item['mobile'] = $userInfo->binding;
- }
- }
- }
- $item['created_at'] = date("Y-m-d H:i", $item['created_at']);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- public function actionSupplierReferralShareLog()
- {
- $supplier_name = get_params('supplier_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $start_date = get_params('start_date');
- $end_date = get_params('end_date');
- $query = SaasUserPriceLog::find()->alias('sr')
- ->leftJoin(['su' => SaasUser::tableName()], 'sr.saas_id = su.id')
- ->leftJoin(['ssr' => SaasSupplierReferral::tableName()], 'ssr.referral_id = su.id')
- ->leftJoin(['s' => Supplier::tableName()], 'ssr.supplier_id = s.id')
- ->where(['sr.amount_type' => SaasUserPriceLog::AMOUNT_TYPE_SUPPLIER_PARENT]);
- if ($supplier_name) {
- $query->andWhere(['like', 's.name', $supplier_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'su.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'su.mobile', $mobile]);
- }
- if ($start_date) {
- $query->andWhere(['>=', 'sr.created_at', strtotime($start_date)]);
- }
- if ($end_date) {
- $query->andWhere(['<=', 'sr.created_at', strtotime($end_date)]);
- }
- $query->select('sr.*, su.avatar, su.name, su.mobile, s.name as supplier_name');
- $list = pagination_make($query);
- foreach ($list['list'] as &$item) {
- $item['created_at'] = date("Y-m-d H:i", $item['created_at']);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- /**
- * 消费返利列表
- * @return \yii\web\Response
- */
- public function actionStoreSelfRebateList()
- {
- $store_name = get_params('store_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $status = get_params('status', -1);
- if (!in_array($status, [-1, 0, 1])) {
- $status = -1;
- }
- $query = Store::find()->alias('s')->leftJoin(['a' => Admin::tableName()], 's.admin_id = a.id');
- $query->where(['s.is_delete' => 0]);
- if ($store_name) {
- $query->andWhere(['like', 's.name', $store_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'a.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'a.mobile', $mobile]);
- }
- if ($status > -1) {
- $query->andWhere(['s.self_rebate_switch' => $status]);
- }
- $query->select('s.id, s.name as store_name, s.logo, a.name as nickname, a.mobile, s.self_rebate_switch, s.self_rebate_value');
- $list = pagination_make($query);
- foreach ($list['list'] as &$item) {
- $amount = SharingReceiver::find()->where([
- 'store_id' => $item['id'],
- 'from' => 1,
- 'is_delete' => 0,
- ])->andWhere(['like', 'remark', '自购返利'])->sum('amount');
- $item['income'] = $amount ?: '0.00';
- $item['use_default'] = 0;
- if($item['self_rebate_switch'] != 0 && $item['self_rebate_value'] == 0){
- $defaultSet = Option::get(OptionSetting::SHARE_SELF_REBATE_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME, '{}');
- $defaultSet = json_decode($defaultSet['value'], true);
- if(!empty($defaultSet['self_rebate_switch']) && !empty($defaultSet['self_rebate_value'])){
- $item['self_rebate_value'] = $defaultSet['self_rebate_value'];
- $item['use_default'] = 1;
- }
- }
- }
- //默认配置
- $defaultSet = Option::get(OptionSetting::SHARE_SELF_REBATE_DEFAULT_SETTING, -1, OptionSetting::SHARE_GROUP_NAME, '{}');
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'defaultSet' => json_decode($defaultSet['value']),
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- /**
- * 编辑消费返利设置
- * @return \yii\web\Response
- * @throws \yii\base\InvalidConfigException
- * @throws \yii\db\StaleObjectException
- * @throws \yii\db\Exception
- * @author Syan mzsongyan@gmail.com
- * @date 2022-05-13
- */
- public function actionStoreSelfRebateOption()
- {
- $store_id = post_params('store_id');
- $switch = post_params('switch');
- $rate = post_params('rate');
- //默认配置
- if(intval($store_id) === -1){
- $json = json_encode([
- 'self_rebate_switch' => $switch,
- 'self_rebate_value' => $rate,
- ]);
- $res = Option::set(OptionSetting::SHARE_SELF_REBATE_DEFAULT_SETTING, $json, $store_id, OptionSetting::SHARE_GROUP_NAME);
- if(!$res){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '默认配置编辑失败',
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '默认配置编辑成功',
- ]);
- }
- if (!$store_id || $switch === null) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '缺少必要参数',
- ]);
- }
- if (!in_array($switch, [0, 1])) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数错误',
- ]);
- }
- $store = Store::findOne($store_id);
- if (!$store) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '商城不存在',
- ]);
- }
- $store->self_rebate_switch = $switch;
- if ($rate !== null) {
- $store->self_rebate_value = $rate;
- }
- if (!union_share_scale_check($store)) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '保存失败,分销比例不能超过100%',
- ]);
- }
- if ($store->save()) {
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功',
- ]);
- }
- return $this->asJson([
- 'code' => 1,
- 'msg' => '保存失败',
- ]);
- }
- /**
- * 消费返利佣金明细
- * @return \yii\web\Response
- * @throws \yii\base\InvalidConfigException
- * @throws \Throwable
- * @throws \yii\db\Exception
- * @author Syan mzsongyan@gmail.com
- * @date 2022-05-13
- */
- public function actionStoreSelfRebateLog()
- {
- $store_name = get_params('store_name');
- $nickname = get_params('nickname');
- $mobile = get_params('mobile');
- $status = get_params('status', -1);
- $start_date = get_params('start_date');
- $end_date = get_params('end_date');
- if (!in_array($status, [-1, 0, 1])) {
- $status = -1;
- }
- $query = SharingReceiver::find()->alias('sr')->leftJoin(['s' => Store::tableName()], 'sr.store_id = s.id')
- //->leftJoin(['su' => SaasUser::tableName()], 'sr.user_id = su.id')
- ->leftJoin(['su' => SaasUser::tableName()], 'sr.saas_id = su.id')
- ->where(['sr.is_delete' => 0, 'sr.from' => 5]);
- $query->andWhere(['like', 'sr.remark', '自购返利']);
- if ($store_name) {
- $query->andWhere(['like', 's.name', $store_name]);
- }
- if ($nickname) {
- $query->andWhere(['like', 'su.name', $nickname]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'su.mobile', $mobile]);
- }
- if ($status > -1) {
- $query->andWhere(['sr.is_pay' => $status]);
- }
- if ($start_date) {
- $query->andWhere(['>=', 'sr.created_at', strtotime($start_date)]);
- }
- if ($end_date) {
- $query->andWhere(['<=', 'sr.created_at', strtotime($end_date)]);
- }
- $query->select('sr.id, su.avatar, su.name, su.mobile, sr.order_no, s.name as store_name, sr.rate, sr.amount, sr.is_pay, sr.created_at, sr.err_code_des ,sr.execute_type, sr.updated_at , sr.created_at ');
- $query->orderBy('sr.created_at desc');
- $list = pagination_make($query);
- foreach ($list['list'] as &$item) {
- if(!$item['avatar'] && $item['id']){
- $userInfo = User::find()->where(['id' => $item['id'], 'is_delete' => 0])->one();
- if(!empty($userInfo) && !empty($userInfo->avatar_url)){
- $item['avatar'] = $userInfo->avatar_url;
- $item['name'] = $userInfo->nickname;
- }
- }
- $item['created_at'] = date("Y-m-d H:i", $item['created_at']);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount'],
- ]
- ]);
- }
- //设置入驻协议
- public function actionSaasProtocol() {
- try {
- if (\Yii::$app->request->isPost) {
- $data = post_params();
- //店铺入驻协议
- if (!empty($data['store_apply_agreement'])) {
- Option::set('store_apply_agreement', $data['store_apply_agreement'], 0, 'saas');
- }
- //采购申请协议
- if (!empty($data['cloud_apply_agreement'])) {
- Option::set('cloud_apply_agreement', $data['cloud_apply_agreement'], 0, 'saas');
- }
- //供货商入驻协议
- if (!empty($data['cloud_supplier_apply_agreement'])) {
- Option::set('cloud_supplier_apply_agreement', $data['cloud_supplier_apply_agreement'], 0, 'saas');
- }
- //区域管理协议
- if (!empty($data['area_agent_apply_agreement'])) {
- Option::set('area_agent_apply_agreement', $data['area_agent_apply_agreement'], 0, 'saas');
- }
- //推广代理申请协议
- if (!empty($data['bd_agent_apply_agreement'])) {
- Option::set('bd_agent_apply_agreement', $data['bd_agent_apply_agreement'], 0, 'saas');
- }
- //产品代理入驻协议
- if (!empty($data['goods_agent_apply_agreement'])) {
- Option::set('goods_agent_apply_agreement', $data['goods_agent_apply_agreement'], 0, 'saas');
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => "设置完成"
- ]);
- } else {
- $keys = [
- 'store_apply_agreement',
- 'cloud_apply_agreement',
- 'cloud_supplier_apply_agreement',
- 'area_agent_apply_agreement',
- 'bd_agent_apply_agreement',
- 'goods_agent_apply_agreement',
- ];
- $data = Option::get($keys, 0, 'saas');
- if (empty($data)) {
- $data = [
- 'store_apply_agreement' => '',
- 'cloud_apply_agreement' => '',
- 'cloud_supplier_apply_agreement' => '',
- 'area_agent_apply_agreement' => '',
- 'bd_agent_apply_agreement' => '',
- 'goods_agent_apply_agreement' => ''
- ];
- } else {
- $arr = [];
- foreach ($data as $value) {
- $index = array_search($value['name'], $keys);
- unset($keys[$index]);
- $arr[$value['name']] = $value['value'];
- }
- foreach ($keys as $key) {
- $arr[$key] = '';
- }
- $data = $arr;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $data,
- ]);
- }
- } catch (\Exception $e) {
- return $this->asJson(
- [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ]
- );
- }
- }
- public function actionWechatCashConfig() {
- try {
- $store_id = get_store_id();
- if (\Yii::$app->request->isPost) {
- $params = post_params();
- $data = [
- 'is_open' => $params['is_open'] ?: 1,//是否使用新版商家转账(申请后可以用)//https://pay.weixin.qq.com/doc/v3/merchant/4012711988
- 'mch_id' => $params['mch_id'] ?: '',
- 'appid' => $params['appid'] ?: '',
- 'mch_private_key' => $params['mch_private_key'] ?: '',
- 'mch_api_key' => $params['mch_api_key'] ?: '',
- 'serial_no' => $params['serial_no'] ?: '',
- 'mch_public_key' => $params['mch_public_key'] ?: '',
- 'pay_public_key' => $params['pay_public_key'] ?: '',
- 'pay_public_key_id' => $params['pay_public_key_id'] ?: '',
- ];
- Option::set('wechat_cash', json_encode($data), $store_id, 'store');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功'
- ]);
- } else {
- $data = json_encode([
- 'is_open' => 1,
- 'mch_id' => '',
- 'appid' => '',
- 'mch_private_key' => '',
- 'serial_no' => '',
- 'mch_api_key' => '',
- 'mch_public_key' => '',
- 'pay_public_key' => '',
- 'pay_public_key_id' => '',
- ]);
- $wechat_cash = Option::get('wechat_cash', $store_id, 'store')['value'];
- if (!$wechat_cash) {
- $wechat_cash = $data;
- }
- $wechat_cash = json_decode($wechat_cash, true);
- if (!isset($wechat_cash['is_open'])) {
- $wechat_cash['is_open'] = 1;
- }
- if (!isset($wechat_cash['mch_api_key'])) {
- $wechat_cash['mch_api_key'] = '';
- }
- if (!isset($wechat_cash['mch_public_key'])) {
- $wechat_cash['mch_public_key'] = '';
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '获取成功',
- 'data' => $wechat_cash
- ]);
- }
- } catch (\Exception $e) {
- return $this->asJson(
- [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ]
- );
- }
- }
- public function actionStoreWechatCashConfig() {
- try {
- $store_id = get_store_id();
- if (\Yii::$app->request->isPost) {
- $params = post_params();
- $data = [
- 'is_open' => $params['is_open'] ?: '',//是否使用新版商家转账(申请后可以用)//https://pay.weixin.qq.com/doc/v3/merchant/4012711988
- 'mch_id' => $params['mch_id'] ?: '',
- 'appid' => $params['appid'] ?: '',
- 'mch_private_key' => $params['mch_private_key'] ?: '',
- 'mch_api_key' => $params['mch_api_key'] ?: '',
- 'serial_no' => $params['serial_no'] ?: '',
- 'mch_public_key' => $params['mch_public_key'] ?: '',
- 'pay_public_key' => $params['pay_public_key'] ?: '',
- 'pay_public_key_id' => $params['pay_public_key_id'] ?: '',
- ];
-
- Option::set('store_wechat_cash', json_encode($data), $store_id, 'store');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功'
- ]);
- } else {
- $data = json_encode([
- 'is_open' => 1,
- 'mch_id' => '',
- 'appid' => '',
- 'mch_private_key' => '',
- 'mch_api_key' => '',
- 'serial_no' => '',
- 'mch_public_key' => '',
- 'pay_public_key' => '',
- 'pay_public_key_id' => '',
- ]);
- $store_wechat_cash = Option::get('store_wechat_cash', $store_id, 'store')['value'];
- if (!$store_wechat_cash) {
- $store_wechat_cash = $data;
- }
- $store_wechat_cash = json_decode($store_wechat_cash, true);
- if (!isset($store_wechat_cash['is_open'])) {
- $store_wechat_cash['is_open'] = 1;
- }
- if (!isset($store_wechat_cash['mch_api_key'])) {
- $store_wechat_cash['mch_api_key'] = '';
- }
- if (!isset($store_wechat_cash['mch_public_key'])) {
- $store_wechat_cash['mch_public_key'] = '';
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '获取成功',
- 'data' => $store_wechat_cash
- ]);
- }
- } catch (\Exception $e) {
- return $this->asJson(
- [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ]
- );
- }
- }
- public function actionProfitStrategyUpdate() {
- $id = \Yii::$app->cache->get('profit_strategy_job_id');
- if ($id && !\Yii::$app->queue->isDone($id)) {
- \Yii::$app->queue->remove($id);
- }
- $id = \queue_push(new \app\jobs\SetProfitStrategyJob(), 0, 1);
- \Yii::$app->cache->set('profit_strategy_job_id', $id);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '正在更新,请稍后'
- ]);
- }
- //设置策略
- public function actionProfitStrategy() {
- try {
- if (\Yii::$app->request->isPost) {
- $params = post_params();
- $data = [
- 'service_charge_model' => $params['service_charge_model'] ?: 0,//服务收费模式
- 'service_charge_rate' => $params['service_charge_rate'] ?: sprintf('%.2f', '0'),//抽成比例
- 'is_risk_control' => $params['is_risk_control'] ?: 0,//是否开启风控
- 'risk_control_model' => $params['risk_control_model'] ?: 0,//风控规则
- // 'is_markup_protection' => $params['is_markup_protection'] ?: 0,//加价保护是否开启
- // 'markup_protection_rules' => [//加价保护规则
- // 'title' => $params['markup_protection_rules']['title'] ?: 0,//加价保护规则名称
- // 'compare' => $params['markup_protection_rules']['compare'] ?: 0,
- // 'price' => $params['markup_protection_rules']['price'] ?: sprintf('%.2f', '0'),
- // 'operate' => $params['markup_protection_rules']['operate'] ?: 0,
- // ]
- ];
- Option::set('platform_profit_strategy', json_encode($data), 0, 'store');
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功'
- ]);
- } else {
- $data = json_encode([
- 'service_charge_model' => 0,//服务收费模式
- 'service_charge_rate' => sprintf('%.2f', '0'),//抽成比例
- 'is_risk_control' => 0,//是否开启风控
- 'risk_control_model' => 0,//风控规则
- // 'is_markup_protection' => 0,//加价保护是否开启
- // 'markup_protection_rules' => [//加价保护规则
- // 'title' => 0,//加价保护规则名称
- // 'compare' => 0,
- // 'price' => sprintf('%.2f', '0'),
- // 'operate' => 0,
- // ]
- ]);
- $wechat_cash = Option::get('platform_profit_strategy', 0, 'store')['value'];
- if (!$wechat_cash) {
- $wechat_cash = $data;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '获取成功',
- 'data' => json_decode($wechat_cash, true)
- ]);
- }
- } catch (\Exception $e) {
- return $this->asJson(
- [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ]
- );
- }
- }
- public function actionGetVersion() {
- $type = get_params('type');
- $key = 'store_dandianpu_version';
- if ($type == 'merchant') {
- $key = 'store_merchant_version';
- }
- $cache = cacheLock();
- return $this->asJson([
- 'code' => 0,
- 'data' => [
- 'version' => $cache->get($key) ?: '',
- 'cyy_version' => cyy_version()
- ]
- ]);
- }
- // 判断供应链版本是否有h5端权限
- public function actionCheckDandianpuHasH5()
- {
- $cliented = \Yii::$app->getAttr('client');
- return $this->asJson([
- 'code' => 0,
- 'data' => \Yii::$app->prod_is_dandianpu() ? in_array('h5', $cliented['store']) : true,
- ]);
- }
- }
|