| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400 |
- <?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', '');
- $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('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 {
- $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' => [
- '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,
- ]);
- }
- }
|