| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895 |
- <?php
- /**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/2/24
- * Time: 下午12:48
- */
- namespace backendApi\modules\v1\controllers;
- use backendApi\modules\v1\models\AdminCountry;
- use backendApi\modules\v1\models\AdminRole;
- use backendApi\modules\v1\models\exportForms\BonusExportForm;
- use backendApi\modules\v1\models\lists\bonus\BalanceList;
- use backendApi\modules\v1\models\lists\bonus\FlowBalanceList;
- use backendApi\modules\v1\models\lists\bonus\FlowBonusList;
- use backendApi\modules\v1\models\lists\bonus\FlowExchangePointsList;
- use backendApi\modules\v1\models\lists\bonus\FlowReconsumePointsList;
- use backendApi\modules\v1\models\lists\bonus\FlowWalletList;
- use backendApi\modules\v1\models\lists\bonus\PerfMonthList;
- use backendApi\modules\v1\models\lists\bonus\PerfOrderList;
- use backendApi\modules\v1\models\lists\bonus\PerfPeriodList;
- use backendApi\modules\v1\models\lists\bonus\PerfStandardList;
- use backendApi\modules\v1\models\lists\bonus\PeriodBonusList;
- use backendApi\modules\v1\models\lists\bonus\ScoreMonthList;
- use backendApi\modules\v1\models\lists\bonus\TraceDownBdList;
- use backendApi\modules\v1\models\lists\bonus\TraceDownGlList;
- use backendApi\modules\v1\models\lists\bonus\TraceDownGxList;
- use backendApi\modules\v1\models\lists\bonus\TraceDownQyList;
- use backendApi\modules\v1\models\lists\bonus\TraceDownTgList;
- use backendApi\modules\v1\models\lists\bonus\TraceDownXfList;
- use backendApi\modules\v1\models\lists\bonus\TraceDownYcList;
- use backendApi\modules\v1\models\lists\bonus\TraceDownYjList;
- use backendApi\modules\v1\models\lists\bonus\TraceUpBdList;
- use backendApi\modules\v1\models\lists\bonus\TraceUpGlList;
- use backendApi\modules\v1\models\lists\bonus\TraceUpGxList;
- use backendApi\modules\v1\models\lists\bonus\TraceUpQyList;
- use backendApi\modules\v1\models\lists\bonus\TraceUpTgList;
- use backendApi\modules\v1\models\lists\bonus\TraceUpXfList;
- use backendApi\modules\v1\models\lists\bonus\TraceUpYcList;
- use backendApi\modules\v1\models\lists\bonus\TraceUpYjList;
- use backendApi\modules\v1\models\lists\bonus\UserPerfList;
- use common\helpers\Cache;
- use common\helpers\Tool;
- use common\helpers\user\Info;
- use common\helpers\user\Perf;
- use common\models\CalcBonus;
- use common\models\CFLXAudit;
- use common\models\forms\PerfAdjustmentForm;
- use common\models\forms\ResendQYForm;
- use common\models\forms\SendCFAndLXForm;
- use common\models\PerfMonth;
- use common\models\PerfOrder;
- use common\models\PerfPeriod;
- use common\models\ResendQYAudit;
- use common\models\User;
- use common\models\UserInfo;
- use common\models\UserNetwork;
- use common\models\UserPerf;
- use Yii;
- use common\helpers\Form;
- use common\models\FlowBonus;
- use common\models\forms\PeriodForm;
- use common\models\forms\UserBonusForm;
- use common\models\Period;
- use yii\db\Exception;
- use yii\web\HttpException;
- class BonusController extends BaseController {
- public $modelClass = FlowBonus::class;
- public function behaviors() {
- return parent::behaviors();
- }
- /**
- * 期数列表
- * @return mixed
- * @throws \yii\base\InvalidConfigException
- * @throws \yii\httpclient\Exception
- * @throws HttpException
- * @throws Exception
- */
- public function actionPeriod() {
- $filter = $this->filterCondition([
- 'periodNum' => 'PERIOD_NUM',
- 'year' => 'CALC_YEAR',
- 'month' => 'CALC_MONTH',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $periodObj = Period::instance();
- $nowPeriodNum = $periodObj->getNowPeriodNum();
- // $condition .= ' AND PERIOD_NUM<=:PERIOD_NUM AND STATUS=1';
- $condition .= ' AND STATUS=1';
- // $params[':PERIOD_NUM'] = $nowPeriodNum;
- $data = Period::lists($condition, $params, ['orderBy' => 'PERIOD_NUM ASC']);
- foreach ($data['list'] as $key => $value) {
- // 结算月
- $data['list'][$key]['CALC_YEAR_MONTH'] = $periodObj->getYearMonth($value['PERIOD_NUM']);
- // 结算
- $data['list'][$key]['IS_CAN_CALC'] = $periodObj->isCanCalc($value['PERIOD_NUM']);
- // 挂网
- $data['list'][$key]['IS_CAN_SENT'] = $periodObj->isCanSend($value['PERIOD_NUM']);
- // 日志
- $data['list'][$key]['IS_SHOW_LOG'] = $value['CALCULATED_AT'] > 0;
- }
- return static::notice($data);
- }
- /**
- * 结算
- * @return mixed
- * @throws HttpException
- */
- public function actionCalcPeriod() {
- $periodNum = \Yii::$app->request->get('periodNum');
- if (!$periodNum) {
- return static::notice('期数不存在', 400);
- }
- $formModel = new PeriodForm();
- $formModel->scenario = 'calc';
- if ($formModel->load(Yii::$app->request->get(), '') && $formModel->calcWebToAsync()) {
- return static::notice('结算已开始处理,请等待');
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- /**
- * 挂网
- * @return mixed
- * @throws HttpException
- */
- public function actionSendPeriod() {
- $periodNum = \Yii::$app->request->get('periodNum');
- if (!$periodNum) {
- return static::notice('期数不存在', 400);
- }
- $formModel = new PeriodForm();
- $formModel->scenario = 'send';
- if ($formModel->load(Yii::$app->request->get(), '') && $formModel->sendWebToAsync()) {
- return static::notice('挂网已开始处理,请等待');
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- /**
- * 查看业绩
- * @return mixed
- * @throws HttpException
- */
- public function actionPerf() {
- // 获取当前年月
- $period = Period::instance();
- $yearMonth = $period->getNowYearMonth();
- $yearMonth = Yii::$app->request->get('yearMonth', $yearMonth);
- //$filter = $this->filterCondition(Perf::tableName(), ['periodNum'=>'P.PERIOD_NUM', 'userName'=>'UI.USER_NAME']);
- $condition = '';
- $params = [];
- $data = PerfPeriod::lists($condition, $params, [
- 'select' => 'P.*, UI.USER_NAME',
- 'yearMonth' => $yearMonth,
- 'from' => PerfPeriod::tableName() . ' AS P',
- 'join' => [
- ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'P.USER_ID=UI.USER_ID']
- ],
- 'orderBy' => 'P.PERIOD_NUM DESC',
- ]);
- $data['request'] = [];
- $data['request']['yearMonth'] = $yearMonth;
- return static::notice($data);
- }
- /**
- * 奖金流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionFlowBonus() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'REAL_NAME' => 'U.REAL_NAME',
- 'IS_DEC' => 'U.IS_DEC',
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'FB.CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- 'TRANSFER_SN' => 'TRANSFER_SN',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $listObj = new FlowBonusList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 奖金流水
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionFlowBonusExport() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'REAL_NAME' => 'U.REAL_NAME',
- 'IS_DEC' => 'U.IS_DEC',
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'FB.CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'LAST_STATUS_NAME' => 'LAST_STATUS',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- 'TRANSFER_SN' => 'TRANSFER_SN',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], 'Bonus_Flow'); // 奖金流水
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 复消积分流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionFlowRp() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new FlowReconsumePointsList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 复消积分流水导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionFlowRpExport() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '复消积分流水');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 会员余额流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionFlowBalance() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'USER_NAME',
- 'REAL_NAME' => 'REAL_NAME',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'TRANSFER_SN' => 'TRANSFER_SN',
- 'CREATED_AT' => 'FW.CREATED_AT',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'REMARK' => 'REMARK',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new FlowBalanceList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 会员余额流水导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionFlowBalanceExport() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'USER_NAME',
- 'REAL_NAME' => 'REAL_NAME',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'TRANSFER_SN' => 'TRANSFER_SN',
- 'CREATED_AT' => 'FW.CREATED_AT',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'REMARK' => 'REMARK',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '会员余额流水');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 兑换积分流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionFlowExchange() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new FlowExchangePointsList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 兑换积分流水导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionFlowExchangeExport() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '兑换积分流水');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 现金钱包流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionFlowWallet() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'REAL_NAME' => 'U.REAL_NAME',
- 'IS_DEC' => 'U.IS_DEC',
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new FlowWalletList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 现金钱包流水导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionFlowWalletExport() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'REAL_NAME' => 'U.REAL_NAME',
- 'IS_DEC' => 'U.IS_DEC',
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '现金钱包流水');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 车房流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionFlowCf() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'LAST_STATUS_NAME' => 'LAST_STATUS',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new FlowCfList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 车房养老奖流水导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionFlowCfExport() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'LAST_STATUS_NAME' => 'LAST_STATUS',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '车房养老奖流水');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 领袖分红流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionFlowLx() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'LAST_STATUS_NAME' => 'LAST_STATUS',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new FlowLxList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionFlowLxExport() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'CREATED_AT' => 'CREATED_AT',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'CALC_MONTH' => 'CALC_MONTH',
- 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'LAST_STATUS_NAME' => 'LAST_STATUS',
- 'AMOUNT' => 'AMOUNT',
- 'TOTAL' => 'TOTAL',
- 'ADMIN_NAME' => 'ADMIN_NAME',
- 'REMARK' => 'REMARK',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '领袖分红奖流水');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 车房养老奖和领袖分红年度发放审核列表
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionCfLxAuditList() {
- $filter = $this->filterCondition([
- 'userIds' => 'CFLXA.USER_ID',
- 'CF' => 'CFLXA.CF',
- 'LX' => 'CFLXA.LX',
- 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
- 'CREATED_AT' => 'CFLXA.CREATED_AT',
- 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
- 'AUDITED_AT' => 'CFLXA.AUDITED_AT',
- 'CREATE_REMARK' => 'CFLXA.CREATE_REMARK',
- 'filterStatus' => 'CFLXA.AUDIT_STATUS',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new CfLxAuditList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 车房养老奖和领袖分红年度发放审核导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionCfLxAuditExport() {
- $filter = $this->filterCondition([
- 'userIds' => 'CFLXA.USER_ID',
- 'CF' => 'CFLXA.CF',
- 'LX' => 'CFLXA.LX',
- 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
- 'CREATED_AT' => 'CFLXA.CREATED_AT',
- 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
- 'AUDITED_AT' => 'CFLXA.AUDITED_AT',
- 'CREATE_REMARK' => 'CFLXA.CREATE_REMARK',
- 'filterStatus' => 'CFLXA.AUDIT_STATUS',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '年度奖金发放审核');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 申请发放车房养老奖和领袖分红
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionCfLxApply() {
- if (Yii::$app->request->isPost) {
- $formModel = new SendCFAndLXForm();
- $formModel->scenario = 'apply';
- if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->apply()) {
- if(!empty($result['logs'])){
- return static::notice('申请成功,请在年度奖管理中审核');
- }else{
- return static::notice('申请失败,无符合发放条件会员',400);
- }
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- return static::notice('Illegal request', 400); // 非法请求
- }
- /**
- * 审核车房养老奖和领袖分红
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionCfLxAudit() {
- $formModel = new SendCFAndLXForm();
- $formModel->scenario = 'audit';
- if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
- return static::notice('审核年度奖申请完成');
- }
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- /**
- * 删除车房领袖审核信息
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionCfLxAuditDelete() {
- $sendCFAndLXForm = new SendCFAndLXForm();
- $result = static::delete(CFLXAudit::class, function ($selected) use ($sendCFAndLXForm) {
- $sendCFAndLXForm->beforeDelete($selected);
- // Log::adminHandle('删除审核会员余额信息');
- }, function ($selected) use ($sendCFAndLXForm) {
- $sendCFAndLXForm->delete($selected);
- // Log::adminHandle('删除审核会员余额信息');
- }, true);
- return $result;
- }
- /**
- * 查看所传期数的各项奖金
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionPeriodDetail() {
- $periodNum = \Yii::$app->request->get('periodNum');
- $period = Period::instance();
- $periodInfo = $period->setPeriodNum($periodNum);
- $yearMonth = $period->getYearMonth($periodNum);
- // $filter = $this->filterCondition('UT', [
- // 'userName' => 'UI.USER_NAME',
- // ]);
- $condition = '';
- $params = [];
- $condition .= ' AND C.PERIOD_NUM=:PERIOD_NUM';
- $params[':PERIOD_NUM'] = $periodNum;
- if (!$period->isClosed($periodNum)) {
- return static::notice('Cannot view this period'); // 该期不能查看
- }
- $data = CalcBonus::lists($condition, $params, [
- 'yearMonth' => $yearMonth,
- 'select' => 'C.*,UI.USER_NAME',
- 'from' => CalcBonus::tableName() . ' AS C',
- 'join' => [
- ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'C.USER_ID=UI.USER_ID'],
- ],
- 'orderBy' => 'C.CREATED_AT DESC',
- ]);
- $data['periodInfo'] = $periodInfo;
- return static::notice($data);
- }
- /**
- * 获取最新一期结算的奖金
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionNewPeriodBonus() {
- $periodNum = Period::calculatedMaxPeriodNum();
- $data = $this->_periodBonus($periodNum);
- return static::notice($data);
- }
- /**
- * 最新一期奖金导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionNewPeriodBonusExport() {
- $filter = $this->filterCondition([
- 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
- 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
- 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
- 'LAST_MOBILE' => 'CB.LAST_MOBILE',
- 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
- 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
- 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
- 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
- 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
- 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
- 'BONUS_BD' => 'CB.BONUS_BD',
- 'BONUS_TG' => 'CB.BONUS_TG',
- 'BONUS_YJ' => 'CB.BONUS_YJ',
- 'BONUS_GX' => 'CB.BONUS_GX',
- // 'BONUS_GL' => 'CB.BONUS_BS',
- 'BONUS_GL' => 'CB.BONUS_GL',
- 'BONUS_QY' => 'CB.BONUS_QY',
- 'BONUS_YC' => 'CB.BONUS_YC',
- 'PV_1L' => 'CB.PV_1L',
- 'SURPLUS_1L' => 'CB.SURPLUS_1L',
- 'PV_2L' => 'CB.PV_2L',
- 'SURPLUS_2L' => 'CB.SURPLUS_2L',
- 'PV_3L' => 'CB.PV_3L',
- 'SURPLUS_3L' => 'CB.SURPLUS_3L',
- 'CALCULATED_AT' => 'CB.CALCULATED_AT',
- 'CALC_MONTH' => 'CB.CALC_MONTH',
- 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
- ]);
- $periodNum = Period::calculatedMaxPeriodNum();
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter['condition'] .= ' AND PERIOD_NUM=:PERIOD_NUM';
- $filter['params'][':PERIOD_NUM'] = $periodNum;
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth]]), '最新奖金');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 获取往期已结算的奖金
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionOtherPeriodBonus() {
- $periodNumRequest = \Yii::$app->request->get('periodNum');
- if(!$periodNumRequest){
- $periodNum = Period::calculatedMaxPeriodNum();
- }else{
- $periodNum = explode(",", $periodNumRequest)[1];
- }
- $data = $this->_periodBonus($periodNum,false);
- if( isset($data['filterTypes']) && is_array($data['filterTypes']) ) {
- $data['filterTypes'] = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> \Yii::t('ctx', 'payCycle')]], $data['filterTypes']);
- }
- return static::notice($data);
- }
- /**
- * 往期奖金导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionOtherPeriodBonusExport() {
- $filter = $this->filterCondition([
- 'periodNum' => 'CB.PERIOD_NUM',
- 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
- 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
- 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
- 'LAST_MOBILE' => 'CB.LAST_MOBILE',
- 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
- 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
- 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
- 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
- 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
- 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
- 'BONUS_BD' => 'CB.BONUS_BD',
- 'BONUS_TG' => 'CB.BONUS_TG',
- 'BONUS_YJ' => 'CB.BONUS_YJ',
- 'BONUS_GX' => 'CB.BONUS_GX',
- 'BONUS_GL' => 'CB.BONUS_GL',
- 'BONUS_QY' => 'CB.BONUS_QY',
- 'BONUS_YC' => 'CB.BONUS_YC',
- 'PV_1L' => 'CB.PV_1L',
- 'SURPLUS_1L' => 'CB.SURPLUS_1L',
- 'PV_2L' => 'CB.PV_2L',
- 'SURPLUS_2L' => 'CB.SURPLUS_2L',
- 'PV_3L' => 'CB.PV_3L',
- 'SURPLUS_3L' => 'CB.SURPLUS_3L',
- 'CALCULATED_AT' => 'CB.CALCULATED_AT',
- 'CALC_MONTH' => 'CB.CALC_MONTH',
- 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
- ]);
- $periodNumRequest = \Yii::$app->request->get('periodNum');
- if(!$periodNumRequest){
- $periodNum = Period::calculatedMaxPeriodNum();
- }else{
- $periodNum = explode(",", $periodNumRequest)[1];
- }
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND CU.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $form = new BonusExportForm();
- $result = $form->run(array_merge(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth]]), 'Member Bonus'); // 往期奖金
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 获取筛选类型
- * @return mixed
- * @throws HttpException
- */
- public function actionOtherPeriodBonusFilterTypes(){
- $listObj = new PeriodBonusList();
- $filterTypes = $listObj->getFilterTypes();
- $filterTypes = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> \Yii::t('ctx', 'payCycle')]], $filterTypes);
- return static::notice($filterTypes);
- }
- /**
- * 期数对应的奖金
- * @param $periodNum
- * @param $periodFilter
- * @return array
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- */
- private function _periodBonus($periodNum,$periodFilter = true) {
- $filter = $this->filterCondition([
- 'periodNum' => 'CB.PERIOD_NUM',
- 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
- 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
- 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
- 'LAST_ELITE_LV_NAME' => 'CB.LAST_ELITE_LV',
- 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
- 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
- 'CALC_MONTH' => 'CB.CALC_MONTH',
- 'BONUS_TOTAL' => 'CB.BONUS_TOTAL',
- 'BONUS_E' => 'CB.BONUS_E',
- 'BONUS_PE' => 'CB.BONUS_PE',
- 'BONUS_SE' => 'CB.BONUS_SE',
- 'BONUS_LB' => 'CB.BONUS_LB',
- 'BONUS_ST' => 'CB.BONUS_ST',
- 'BONUS_WB' => 'CB.BONUS_WB',
- 'BONUS_CAR' => 'CB.BONUS_CAR',
- 'BONUS_PB' => 'CB.BONUS_PB',
- ]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $condition = $filter['condition'];
- $params = $filter['params'];
- if($periodFilter){
- $condition .= ' AND CB.PERIOD_NUM=:PERIOD_NUM';
- $params[':PERIOD_NUM'] = $periodNum;
- }
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND CU.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $listObj = new PeriodBonusList();
- return $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth]]);
- }
- /**
- * 团队奖奖金向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownQy() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice(\Yii::t('ctx', 'requirePeriods'), 400);
- $userName = Yii::$app->request->get('userName');
- if (!$userName) return static::notice(\Yii::t('ctx', 'requireMemberNumber'), 400);
- $period = Period::instance();
- if (!$period->isCalculated($periodNum)) {
- return static::notice([]);
- }
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'decType' => 'PO.DEC_TYPE',
- 'periodNum' => 'PO.PERIOD_NUM',
- ]);
- $qyFilter = $this->_qyFilterCondition($filter['request']);
- $filter = array_merge($filter, $qyFilter);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceDownQyList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 获取
- * @param $request
- * @return array|string[]
- */
- private function _qyFilterCondition($request) {
- //根据USER_NAME获取USER_ID
- $user = User::find()->select('ID')->where('USER_NAME=:USER_NAME', ['USER_NAME'=>$request['userName']])->asArray()->one();
- if( !$user ) return [];
- //找到这个会员的LOCATION_TAG
- $userNetwork = UserNetwork::find()->select(['LOCATION_TAG'])->where('USER_ID=:USER_ID', ['USER_ID'=>$user['ID']])->asArray()->one();
- $searchLocationTag = $userNetwork['LOCATION_TAG'];
- if( isset($request['location']) && $request['location'] ) {
- $searchLocationTag .= $request['location'];
- }
- return [
- 'LOCATION_TAG' => 'LIKE ' . $searchLocationTag . '%'
- ];
- }
- /**
- * 团队奖向下追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownQyExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice('请填写期数', 400);
- $userName = Yii::$app->request->get('userName');
- if (!$userName) return static::notice('请填写会员编号', 400);
- $period = Period::instance();
- if (!$period->isCalculated($periodNum)) {
- return static::notice([]);
- }
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'decType' => 'PO.DEC_TYPE',
- 'periodNum' => 'PO.PERIOD_NUM',
- ]);
- $qyFilter = $this->_qyFilterCondition($filter['request']);
- $filter = array_merge($filter, $qyFilter);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '团队奖向下追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 团队奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionTraceUpQy() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice('请填写期数', 400);
- if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
- if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('Member does not exist', 400); // 会员不存在
- //会员是否有业绩单
- if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
- return static::notice('该会员本期没有业绩单', 400);
- }
- $listObj = new TraceUpQyList();
- $data = $listObj->getList(['condition'=>'', 'params'=>[], 'others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 团队奖向上追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpQyExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice('请填写期数', 400);
- if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
- if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('Member does not exist', 400); // 会员不存在
- //会员是否有业绩单
- if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
- return static::notice('该会员本期没有业绩单', 400);
- }
- $form = new BonusExportForm();
- $result = $form->run(array_merge(['condition'=>'', 'params'=>[]], ['others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]), '团队奖向上追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 荣衔奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownYc() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBY.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceDownYcList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 荣衔奖向下追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownYcExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBY.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向下追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 服务奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownBd() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBB.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceDownBdList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 服务奖向下追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownBdExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBB.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '服务奖向下追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 推广奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownTg() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CTG.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceDownTgList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 推广奖向下追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownTgExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CTG.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '推广奖向下追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 消费奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownXf() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CXF.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceDownXfList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 消费奖向下追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownXfExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CXF.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '推广奖向下追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 业绩奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownYj() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CYJ.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceDownYjList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 业绩奖向下追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownYjExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CYJ.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '业绩奖向下追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 共享奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownGx() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CGX.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceDownGxList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 共享奖向下追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownGxExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CGX.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '共享奖向下追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 管理奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownGl() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CGL.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceDownGlList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 管理奖向下追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownGlExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CGL.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '管理奖向下追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 荣衔奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpYc() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBY.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceUpYcList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 荣衔奖向上追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpYcExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBY.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 服务奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpBd() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBB.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceUpBdList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 服务奖向上追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpBdExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBY.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 推广奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpTg() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CTG.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceUpTgList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 推广奖向上追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpTgExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CTG.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 消费奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpXf() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CXF.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceUpXfList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 推广奖向上追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpXfExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CXF.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 业绩奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpYj() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CYJ.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceUpYjList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 业绩奖向上追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpYjExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CYJ.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 共享奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpGx() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CGX.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceUpGxList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 共享奖向上追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpGxExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CGX.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 管理奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpGl() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CGL.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceUpGlList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 管理奖向上追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpGlExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CGL.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 复销奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownFx() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBF.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceDownFxList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 复销奖向下追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceDownFxExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBF.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '复销奖向下追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 复销奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpFx() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBF.PERIOD_NUM',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new TraceUpFxList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
- return static::notice($data);
- }
- /**
- * 复销奖向上追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceUpFxExport() {
- $periodNum = Yii::$app->request->get('periodNum');
- if (!$periodNum) return static::notice([]);
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- 'periodNum' => 'CBF.PERIOD_NUM',
- ]);
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '复销奖向上追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 核算会员区域津贴
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionCalcQy() {
- $periodNum = Yii::$app->request->get('periodNum');
- $userName = Yii::$app->request->get('userName');
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- if (!$userId = Info::getUserIdByUserName($userName)) {
- return static::notice('Member does not exist', 400); // 会员不存在
- }
- $data = CalcBonus::findUseSlaves()->yearMonth($yearMonth)->where('PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID', [':PERIOD_NUM' => $periodNum, ':USER_ID' => $userId])->asArray()->one();
- if ($data) {
- $data['REAL_NAME'] = Info::getUserRealNameByUserId($userId);
- $data['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$data['LAST_DEC_LV']]['LEVEL_NAME']??'';
- $data['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$data['LAST_EMP_LV']]['LEVEL_NAME']??'';
- $data['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$data['LAST_STATUS']]['label']??'';
- $data['AUDIT_STATUS'] = false;
- if ($resendQy = ResendQYAudit::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM AND (AUDIT_STATUS=:AUDIT_STATUS_UN OR AUDIT_STATUS=:AUDIT_STATUS_TRUE)', [':USER_ID' => $userId, ':PERIOD_NUM' => $periodNum, ':AUDIT_STATUS_UN' => \Yii::$app->params['auditStatus']['un']['value'], ':AUDIT_STATUS_TRUE' => \Yii::$app->params['auditStatus']['true']['value']])->asArray()->one()) {
- $data['AUDIT_STATUS'] = $resendQy['AUDIT_STATUS'];
- }
- }
- return static::notice($data);
- }
- /**
- * 补发区域津贴列表
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionResendQyList() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'filterStatus' => 'RESEND_STATUS',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'LAST_STATUS_NAME' => 'LAST_STATUS',
- 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
- 'LAST_AREA_NAME' => [
- 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
- 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
- ],
- 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
- 'BONUS_QY' => 'BONUS_QY',
- 'SHOULD_QY' => 'SHOULD_QY',
- 'QY_1L' => 'QY_1L',
- 'SURPLUS_1L' => 'SURPLUS_1L',
- 'QY_2L' => 'QY_2L',
- 'SURPLUS_2L' => 'SURPLUS_2L',
- 'QY_3L' => 'QY_3L',
- 'SURPLUS_3L' => 'SURPLUS_3L',
- 'QY_4L' => 'QY_4L',
- 'SURPLUS_4L' => 'SURPLUS_4L',
- 'QY_5L' => 'QY_5L',
- 'SURPLUS_5L' => 'SURPLUS_5L',
- 'SURPLUS_LS' => 'SURPLUS_LS',
- 'QY_LS' => 'QY_LS',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new ResendQyList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 区域津贴补发列表导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionResendQyListExport() {
- $filter = $this->filterCondition([
- 'userIds' => 'USER_ID',
- 'filterStatus' => 'RESEND_STATUS',
- 'PERIOD_NUM' => 'PERIOD_NUM',
- 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
- 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
- 'LAST_STATUS_NAME' => 'LAST_STATUS',
- 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
- 'LAST_AREA_NAME' => [
- 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
- 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
- ],
- 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
- 'BONUS_QY' => 'BONUS_QY',
- 'SHOULD_QY' => 'SHOULD_QY',
- 'QY_1L' => 'QY_1L',
- 'SURPLUS_1L' => 'SURPLUS_1L',
- 'QY_2L' => 'QY_2L',
- 'SURPLUS_2L' => 'SURPLUS_2L',
- 'QY_3L' => 'QY_3L',
- 'SURPLUS_3L' => 'SURPLUS_3L',
- 'QY_4L' => 'QY_4L',
- 'SURPLUS_4L' => 'SURPLUS_4L',
- 'QY_5L' => 'QY_5L',
- 'SURPLUS_5L' => 'SURPLUS_5L',
- 'SURPLUS_LS' => 'SURPLUS_LS',
- 'QY_LS' => 'QY_LS',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '区域津贴补发列表');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 补发区域津贴
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionResendQy() {
- if (Yii::$app->request->isPost) {
- $formModel = new ResendQYForm();
- $formModel->scenario = 'apply';
- if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->apply()) {
- if($result['logs']){
- /*foreach ($result['logs'] as $k => $value) {
- $userName = Info::getUserNameByUserId($value);
- // Log::adminHandle('申请为会员' . $userName . '发放补发区域津贴', 0, $value, $userName);
- }*/
- return static::notice('申请成功,请在补发区域津贴审核管理中审核');
- }else{
- return static::notice('没有符合补发条件的记录',400);
- }
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- return static::notice('Illegal request', 400); // 非法请求
- }
- /**
- * 补发审核表
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionResendQyAuditList() {
- $filter = $this->filterCondition([
- 'userIds' => 'RQYA.USER_ID',
- 'filterStatus' => 'RQYA.AUDIT_STATUS',
- 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
- 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
- 'CREATED_AT' => 'RQYA.CREATED_AT',
- 'AUDITED_AT' => 'RQYA.AUDITED_AT',
- 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
- 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
- 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new ResendQyAuditList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 补发审核表导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionResendQyAuditListExport() {
- $filter = $this->filterCondition([
- 'userIds' => 'RQYA.USER_ID',
- 'filterStatus' => 'RQYA.AUDIT_STATUS',
- 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
- 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
- 'CREATED_AT' => 'RQYA.CREATED_AT',
- 'AUDITED_AT' => 'RQYA.AUDITED_AT',
- 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
- 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
- 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '补发区域津贴审核列表');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 审核补发区域津贴
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionResendQyAudit() {
- $formModel = new ResendQYForm();
- $formModel->scenario = 'audit';
- if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
- /*foreach ($result['logs'] as $k => $value) {
- $userName = Info::getUserNameByUserId($value);
- // Log::adminHandle('审核为会员' . $userName . '补发区域津贴', 1, $value, $userName);
- }*/
- return static::notice('审核补发区域津贴成功');
- }
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- /**
- * 删除补发区域津贴审核信息
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionResendQyAuditDelete() {
- $resendQYForm = new ResendQYForm();
- $result = static::delete(ResendQYAudit::class, function ($selected) use ($resendQYForm) {
- $resendQYForm->beforeDelete($selected);
- // Log::adminHandle('删除审核会员余额信息');
- }, function ($selected) use ($resendQYForm) {
- $resendQYForm->delete($selected);
- // Log::adminHandle('删除审核会员余额信息');
- }, true);
- return $result;
- }
- /**
- * 余额列表
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionBalanceList() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'UI.USER_NAME',
- 'REAL_NAME' => 'UI.REAL_NAME',
- 'IS_DEC' => 'UI.IS_DEC',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND UI.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $listObj = new BalanceList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 会员奖金余额导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionBalanceExport() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'UI.USER_NAME',
- 'REAL_NAME' => 'UI.REAL_NAME',
- 'IS_DEC' => 'UI.IS_DEC',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND UI.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '会员奖金余额');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 报单中心店补/补贴追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionTraceBt() {
- $startPeriodNum = Yii::$app->request->get('startPeriodNum');
- $endPeriodNum = Yii::$app->request->get('endPeriodNum');
- if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
- $filterStatus = Yii::$app->request->get('filterStatus');
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- if ($startPeriodNum) {
- $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
- $params[':START_PERIOD_NUM'] = $startPeriodNum;
- }
- if ($endPeriodNum) {
- $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
- $params[':END_PERIOD_NUM'] = $endPeriodNum;
- }
- if ($filterStatus) {
- $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
- $params[':BT_TYPE'] = $filterStatus;
- }
- $listObj = new TraceBtList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 报单中心补贴追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceBtExport() {
- $startPeriodNum = Yii::$app->request->get('startPeriodNum');
- $endPeriodNum = Yii::$app->request->get('endPeriodNum');
- if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
- $filterStatus = Yii::$app->request->get('filterStatus');
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- if ($startPeriodNum) {
- $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
- $params[':START_PERIOD_NUM'] = $startPeriodNum;
- }
- if ($endPeriodNum) {
- $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
- $params[':END_PERIOD_NUM'] = $endPeriodNum;
- }
- if ($filterStatus) {
- $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
- $params[':BT_TYPE'] = $filterStatus;
- }
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心补贴追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 报单中心货补追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionTraceFl() {
- $startPeriodNum = Yii::$app->request->get('startPeriodNum');
- $endPeriodNum = Yii::$app->request->get('endPeriodNum');
- if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- if ($startPeriodNum) {
- $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
- $params[':START_PERIOD_NUM'] = $startPeriodNum;
- }
- if ($endPeriodNum) {
- $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
- $params[':END_PERIOD_NUM'] = $endPeriodNum;
- }
- $listObj = new TraceFlList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 报单中心货补追溯导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceFlExport() {
- $startPeriodNum = Yii::$app->request->get('startPeriodNum');
- $endPeriodNum = Yii::$app->request->get('endPeriodNum');
- if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- if ($startPeriodNum) {
- $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
- $params[':START_PERIOD_NUM'] = $startPeriodNum;
- }
- if ($endPeriodNum) {
- $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
- $params[':END_PERIOD_NUM'] = $endPeriodNum;
- }
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心货补追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 区域业绩提成追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionTraceFw() {
- $startPeriodNum = Yii::$app->request->get('startPeriodNum');
- $endPeriodNum = Yii::$app->request->get('endPeriodNum');
- if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- if ($startPeriodNum) {
- $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
- $params[':START_PERIOD_NUM'] = $startPeriodNum;
- }
- if ($endPeriodNum) {
- $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
- $params[':END_PERIOD_NUM'] = $endPeriodNum;
- }
- $listObj = new TraceFwList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 区域业绩提成导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionTraceFwExport() {
- $startPeriodNum = Yii::$app->request->get('startPeriodNum');
- $endPeriodNum = Yii::$app->request->get('endPeriodNum');
- if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
- $filter = $this->filterCondition([
- 'userName' => 'UI.USER_NAME',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- if ($startPeriodNum) {
- $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
- $params[':START_PERIOD_NUM'] = $startPeriodNum;
- }
- if ($endPeriodNum) {
- $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
- $params[':END_PERIOD_NUM'] = $endPeriodNum;
- }
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '区域业绩提成追溯');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 业绩单
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionPerfOrder(){
- $filter = $this->filterCondition([
- 'PERIOD_NUM' => 'PO.PERIOD_NUM',
- 'SN' => 'PO.SN',
- 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
- 'USER_NAME' => 'U.USER_NAME',
- 'REAL_NAME' => 'U.REAL_NAME',
- 'userIds' => 'PO.USER_ID',
- 'filterType' => 'PO.DEC_TYPE',
- 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
- 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
- 'PV' => 'PO.PV',
- 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
- 'DEC_SN' => 'PO.DEC_SN',
- 'CREATED_AT' => 'PO.CREATED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $listObj = new PerfOrderList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 业绩单导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionPerfOrderExport() {
- $filter = $this->filterCondition([
- 'PERIOD_NUM' => 'PO.PERIOD_NUM',
- 'SN' => 'PO.SN',
- 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
- 'userIds' => 'PO.USER_ID',
- 'filterType' => 'PO.DEC_TYPE',
- 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
- 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
- 'PV' => 'PO.PV',
- 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
- 'DEC_SN' => 'PO.DEC_SN',
- 'LAST_SUB_COM_NAME' => 'PO.LAST_SUB_COM_ID',
- 'LAST_SYSTEM_NAME' => 'PO.LAST_SYSTEM_ID',
- 'LAST_AREA' => [
- 'FIELD' => ['PO.LAST_PROVINCE', 'PO.LAST_CITY', 'PO.LAST_COUNTY'],
- 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
- ],
- 'DEC_USER_NAME' => 'DUI.USER_NAME',
- 'LAST_DEC_DEC_LV_NAME' => 'PO.LAST_DEC_DEC_LV',
- 'LAST_DEC_SUB_COM_NAME' => 'PO.LAST_DEC_SUB_COM_ID',
- 'LAST_DEC_AREA' => [
- 'FIELD' => ['PO.LAST_DEC_PROVINCE', 'PO.LAST_DEC_CITY', 'PO.LAST_DEC_COUNTY'],
- 'BIND' => ['LAST_DEC_PROVINCE', 'LAST_DEC_CITY', 'LAST_DEC_COUNTY'],
- ],
- 'CREATED_AT' => 'PO.CREATED_AT',
- 'CLOSED_AT' => 'PO.CLOSED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '业绩单');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 月积分
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionScoreMonth(){
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'userIds' => 'SM.USER_ID',
- 'CALC_MONTH' => 'SM.CALC_MONTH',
- 'CREATED_AT' => 'SM.CREATED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new ScoreMonthList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 月积分导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionScoreMonthExport() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'userIds' => 'SM.USER_ID',
- 'CALC_MONTH' => 'SM.CALC_MONTH',
- 'CREATED_AT' => 'SM.CREATED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '月积分');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 月业绩
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionPerfMonth(){
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'REC_USER_NAME' => 'RU.USER_NAME',
- 'userIds' => 'PM.USER_ID',
- 'CALC_MONTH' => 'PM.CALC_MONTH',
- 'CREATED_AT' => 'PM.CREATED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $listObj = new PerfMonthList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 月业绩导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionPerfMonthExport() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'REC_USER_NAME' => 'RU.USER_NAME',
- 'userIds' => 'PM.USER_ID',
- 'CALC_MONTH' => 'PM.CALC_MONTH',
- 'CREATED_AT' => 'PM.CREATED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '月业绩');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 期业绩
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionPerfPeriodList(){
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'userIds' => 'PP.USER_ID',
- 'PERIOD_NUM' => 'PP.PERIOD_NUM',
- 'CREATED_AT' => 'PP.CREATED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new PerfPeriodList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 期业绩导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionPerfPeriodListExport() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'userIds' => 'PP.USER_ID',
- 'PERIOD_NUM' => 'PP.PERIOD_NUM',
- 'CREATED_AT' => 'PP.CREATED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '期业绩');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 达标业绩
- * @return mixed
- * @throws \yii\base\Exception
- * @throws HttpException
- */
- public function actionPerfStandard(){
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'REC_USER_NAME' => 'RU.USER_NAME',
- 'userIds' => 'PS.USER_ID',
- 'CALC_MONTH' => 'PS.CALC_MONTH',
- 'CREATED_AT' => 'PS.CREATED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $listObj = new PerfStandardList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 达标业绩导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionPerfStandardExport() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- 'REC_USER_NAME' => 'RU.USER_NAME',
- 'userIds' => 'PS.USER_ID',
- 'CALC_MONTH' => 'PS.CALC_MONTH',
- 'CREATED_AT' => 'PS.CREATED_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '达标业绩');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 会员实时业绩
- * @return mixed
- * @throws HttpException
- */
- public function actionRealTimePerf() {
- $userName = Yii::$app->request->get('userName');
- if (!$userId = Info::getUserIdByUserName($userName)) {
- return static::notice('Member does not exist', 400); // 会员不存在
- }
- $period = Period::instance();
- $newPerf = Perf::getPeriodNewPerf($userId);
- $weekData = [['PV_1L' => $newPerf['PV_1L'], 'PV_2L' => $newPerf['PV_2L'], 'PV_3L' => $newPerf['PV_3L'], 'PV_4L' => $newPerf['PV_4L'], 'PV_5L' => $newPerf['PV_5L'], 'PV_PCS'=>Tool::formatPrice($newPerf['PV_PCS']), 'PV_PSS'=>Tool::formatPrice($newPerf['PV_PSS'])]];
- $monthPerf = Perf::getMonthPerf($userId);
- $monthData = [['PV_1L' => Tool::formatPrice($monthPerf['PV_1L']), 'PV_2L' => Tool::formatPrice($monthPerf['PV_2L']), 'PV_3L' => Tool::formatPrice($monthPerf['PV_3L']), 'PV_4L' => Tool::formatPrice($monthPerf['PV_4L']), 'PV_5L' => Tool::formatPrice($monthPerf['PV_5L']), 'PV_PCS'=>Tool::formatPrice($monthPerf['PV_PCS']), 'PV_PSS'=>Tool::formatPrice($monthPerf['PV_PSS'])]];
- $lastMonth = PerfMonth::getMonthPerf($period->getLastMonth()['yearMonth'], $userId);
- $lastData = [['PV_1L' => Tool::formatPrice($lastMonth['PV_1L_TOTAL']), 'PV_2L' => Tool::formatPrice($lastMonth['PV_2L_TOTAL']), 'PV_3L' => Tool::formatPrice($lastMonth['PV_3L_TOTAL']), 'PV_4L' => Tool::formatPrice($lastMonth['PV_4L_TOTAL']), 'PV_5L' => Tool::formatPrice($lastMonth['PV_5L_TOTAL']), 'PV_PCS'=>Tool::formatPrice($lastMonth['PV_PCS']), 'PV_PSS'=>Tool::formatPrice($lastMonth['PV_PSS']), 'PV_PSS_TOTAL'=>Tool::formatPrice($lastMonth['PV_PSS_TOTAL'])]];
- //是否合格
- // $lastChkStatus = '';
- // $lastMonthPerfChk = Cache::getSystemConfig()['lastMonthPerfChk']['VALUE'];
- // $lastArr = [$lastMonth['PV_1L_TOTAL'], $lastMonth['PV_2L_TOTAL'], $lastMonth['PV_3L_TOTAL'], $lastMonth['PV_4L_TOTAL'], $lastMonth['PV_5L_TOTAL']];
- // if (array_sum($lastArr) >= $lastMonthPerfChk) {
- // $lastChkStatus = '已合格';
- // }
- //判断大区
- // $bigLocation = array_search(max($lastArr), $lastArr) + 1;
- return static::notice(['weekData' => $weekData, 'monthData' => $monthData, 'lastData' => $lastData]);
- }
- /**
- * 荣衔业绩
- * @return mixed
- * @throws HttpException
- */
- public function actionYcPerf() {
- $userName = Yii::$app->request->get('userName');
- if (!$userId = Info::getUserIdByUserName($userName)) {
- return static::notice('Member does not exist', 400); // 会员不存在
- }
- $userPerfData = Perf::getUserPerf($userId);
- $ycPerfList = [];
- //查找推荐的子会员
- $childrenList = UserInfo::findUseDbCalc()->select('USER_ID')->where('REC_UID=:REC_UID', [
- 'REC_UID' => $userId
- ])->asArray()->all();
- $maxPvPss = 0;
- $childSumPerf = 0;
- foreach ($childrenList as $child) {
- $childBaseUser = Info::getBaseUserById($child['USER_ID']);
- if( !$childBaseUser ) continue;
- $childPerfData = Perf::getUserPerf($child['USER_ID']);
- if( !$childPerfData ) continue;
- $childPvPcs = $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'];
- $childPvPssTotal = $childPvPcs + $childPerfData['PV_PSS'];
- $childSumPerf += $childPvPssTotal;
- if( $childPvPssTotal >= $maxPvPss ) {
- $maxPvPss = $childPvPssTotal;
- }
- $ycPerfList[] = [
- 'USER_NAME'=>$childBaseUser['USER_NAME'],
- 'REAL_NAME'=>$childBaseUser['REAL_NAME'],
- 'PV_PCS' => $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'],
- 'PV_PSS_TOTAL' => $childPerfData['PV_PSS_TOTAL'],
- 'MAX_DEPART_PERF' => '-',
- 'OTHER_DEPART_PERF' => '-',
- 'PV_PSS_SUM_TOTAL' => round($childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'] + $childPerfData['PV_PSS_TOTAL'],2),
- ];
- }
- if( $userPerfData ) {
- $baseUser = Info::getBaseUserById($userId);
- $ycPerfData = [
- 'USER_NAME'=>$baseUser['USER_NAME'],
- 'REAL_NAME'=>$baseUser['REAL_NAME'],
- 'PV_PCS' => $userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'],
- 'PV_PSS_TOTAL' => $userPerfData['PV_PSS_TOTAL'],
- 'MAX_DEPART_PERF' => round($maxPvPss, 2),
- 'OTHER_DEPART_PERF' => round($childSumPerf-$maxPvPss, 2),
- 'PV_PSS_SUM_TOTAL' => round($userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'] + $userPerfData['PV_PSS_TOTAL'],2),
- ];
- array_unshift($ycPerfList, $ycPerfData);
- }
- return static::notice(['ycPerfList' => $ycPerfList]);
- }
- /**
- * 用户业绩
- * @return mixed
- * @throws HttpException
- */
- public function actionUserPerf() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $listObj = new UserPerfList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 月业绩导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionUserPerfExport() {
- $filter = $this->filterCondition([
- 'USER_NAME' => 'U.USER_NAME',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
- if (!$isSuper) {
- $adminId = Yii::$app->getUser()->getUserInfo()['id'];
- $adminCountry = AdminCountry::getCountry($adminId);
- $quotedAdminCountry = array_map(function($item) {
- return "'" . addslashes($item) . "'";
- }, $adminCountry);
- $condition .= " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
- }
- $form = new BonusExportForm();
- $result = $form->run(['condition'=>$condition, 'params'=>$params], '用户业绩');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 自动提现(奖金)
- *
- */
- public function actionAutoWithdraw() {
- Cache::setWithdrawLock(0); // todo
- $withdrawLock = Cache::getWithdrawLock();
- if ($withdrawLock!=0){
- return static::notice(Form::formatErrorsForApi('已有进程在生成'), 400);
- }else{
- $formModel = new UserBonusForm();
- $formModel->scenario = 'autoWithdraw';
- if ($formModel->autoWithdrawWebToAsync()) {
- return static::notice('生成提现单 已开始处理,请等待');
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- }
- /**
- * 查询安置网下级会员和业绩、修改业绩
- * @return mixed|void
- * @throws HttpException
- * @throws \yii\base\Exception
- */
- public function actionPerfAdjustment()
- {
- // 查询业绩
- if (\Yii::$app->request->isGet) {
- $memberCode = Yii::$app->request->get('memberCode');
- $userId = Info::getUserIdByUserName(trim($memberCode));
- // 查询传入会员业绩
- $perfMarket = UserPerf::getPerfMarket($userId);
- if ($perfMarket) {
- // 查询传入会员的安置网下级
- $memberList = UserNetwork::getFirstFloorChildren($userId);
- $memberList = array_column($memberList, NULL, 'RELATIVE_LOCATION');
- // 左腿1市场
- $leftPerfUserName = (isset($memberList[1]) && $memberList[1]['USER_ID']) ? Info::getUserNameByUserId($memberList[1]['USER_ID']) : '';
- // 右腿2市场
- $rightPerfUserName = (isset($memberList[2]) && $memberList[2]['USER_ID']) ? Info::getUserNameByUserId($memberList[2]['USER_ID']) : '';
- // 会员编号
- $perfMarket['USER_NAME'] = $memberCode;
- $perfMarket['SURPLUS_1L_USER_NAME'] = $leftPerfUserName;
- $perfMarket['SURPLUS_2L_USER_NAME'] = $rightPerfUserName;
- return static::notice(['allData' => $perfMarket]);
- }
- return static::notice('No data', 400);
- } else if (\Yii::$app->request->isPost) {
- $formModel = new PerfAdjustmentForm();
- $formModel->scenario = 'perfAdjustment';
- $post = \Yii::$app->request->post();
- if ($formModel->load($post, '') && $formModel->perfAdjustment()) {
- return static::notice('Successful');
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- } else {
- return static::notice('Illegal request', 400); // 非法请求
- }
- }
- }
|