| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845 |
- <?php
- /**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/2/24
- * Time: 下午12:48
- */
- namespace backendApi\modules\v1\controllers;
- use backendApi\modules\v1\models\Admin;
- 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\Date;
- use common\helpers\LoggerTool;
- 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 common\models\UserPerfAdjustment;
- use Yii;
- use common\helpers\Form;
- use common\models\Config;
- use common\models\FlowBonus;
- use common\models\FlowExchangePoints;
- use common\models\forms\PeriodForm;
- use common\models\forms\UserBonusForm;
- use common\models\Period;
- use Exception;
- use yii\web\HttpException;
- class BonusController extends BaseController {
- public $modelClass = FlowBonus::class;
- public function behaviors() {
- $behaviors = parent::behaviors();
- //$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
- return $behaviors;
- }
- /**
- * 期数列表
- * @return mixed
- * @throws \yii\base\InvalidConfigException
- * @throws \yii\httpclient\Exception
- * @throws HttpException
- */
- public function actionPeriod() {
- $filter = $this->filterCondition([
- 'periodNum' => 'PERIOD_NUM',
- 'year' => 'CALC_YEAR',
- 'month' => 'CALC_MONTH',
- 'startTime' => 'START_TIME',
- 'endTime' => 'END_TIME',
- 'closedAt' => 'CLOSED_AT',
- 'perfStartedAt' => 'PERF_STARTED_AT',
- 'perfedAt' => 'PERFED_AT',
- 'calStartedAt' => 'CALCULATE_STARTED_AT',
- 'calculatedAt' => 'CALCULATED_AT',
- 'sendStartedAt' => 'SEND_STARTED_AT',
- 'sentAt' => 'SENT_AT',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $periodObj = Period::instance();
- $nowPeriodNum = $periodObj->getNowPeriodNum();
- $condition .= ' AND PERIOD_NUM<=:PERIOD_NUM';
- $params[':PERIOD_NUM'] = $nowPeriodNum;
- $data = Period::lists($condition, $params, ['orderBy' => 'PERIOD_NUM DESC']);
- foreach ($data['list'] as $key => $value) {
- // 是否可封期
- $data['list'][$key]['IS_CAN_CLOSE'] = $periodObj->isCanClose($value['PERIOD_NUM']);
- // 是否可生成业绩单
- $data['list'][$key]['IS_CAN_PERF'] = $periodObj->isCanPerf($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]['BUTTON_IS_CAN'] = $periodObj->isCanClose($value['PERIOD_NUM']) || $periodObj->isCanPerf($value['PERIOD_NUM']) || $periodObj->isCanCalc($value['PERIOD_NUM']) || $periodObj->isCanSend($value['PERIOD_NUM']);
- }
- return static::notice($data);
- }
- /**
- * 封期
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionClosePeriod() {
- $periodNum = \Yii::$app->request->get('periodNum');
- if (!$periodNum) {
- return static::notice('期数不存在', 400);
- }
- $formModel = new PeriodForm();
- if ($formModel->load(Yii::$app->request->get(), '') && $formModel->closePeriod()) {
- // Log::adminHandle('第' . $periodNum . '期封期成功');
- return static::notice('封期成功');
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- /**
- * 计算业绩并生成业绩单
- * @return mixed
- * @throws HttpException
- */
- public function actionPerfPeriod() {
- $periodNum = \Yii::$app->request->get('periodNum');
- if (!$periodNum) {
- return static::notice('期数不存在', 400);
- }
- $formModel = new PeriodForm();
- $formModel->scenario = 'perf';
- if ($formModel->load(Yii::$app->request->get(), '') && $formModel->perfWebToAsync()) {
- // Log::adminHandle('第' . $periodNum . '期封生成业绩单');
- return static::notice('生成业绩单已开始处理,请等待');
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- /**
- * 结算封期
- * @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()) {
- // Log::adminHandle('第' . $periodNum . '期结算');
- 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()) {
- // Log::adminHandle('第' . $periodNum . '期挂网');
- 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',
- // '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'];
- $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',
- ]);
- $form = new BonusExportForm();
- $result = $form->run($filter, '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();
- //return static::notice('请填写期数',400);
- }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'=> 'Pay Cycle(PC)']], $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_GL' => 'CB.BONUS_BS',
- '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];
- }
- // if(!isset($filter['params'][':PERIODNUM'])){
- // return static::notice('请填写期数',400);
- // }
- // $periodNum = $filter['params'][':PERIODNUM'];
- $period = Period::instance();
- $yearMonth = $period->getYearMonth($periodNum);
- // $filter['condition'] .= ' AND CB.PERIOD_NUM=:PERIOD_NUM';
- // $filter['params'][':PERIOD_NUM'] = $periodNum;
- $form = new BonusExportForm();
- $result = $form->run(array_merge($filter, ['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'=> '结算期数']], $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_CROWN_LV_NAME' => 'CB.LAST_CROWN_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_XF' => 'CB.BONUS_XF',
- // 'BONUS_YJ' => 'CB.BONUS_YJ',
- // 'BONUS_GX' => 'CB.BONUS_GX',
- // 'BONUS_GL' => 'CB.BONUS_GL',
- // 'BONUS_GL' => 'CB.BONUS_BS',
- 'BONUS_QY' => 'CB.BONUS_QY',
- // 'BONUS_YC' => 'CB.BONUS_YC',
- // 'ORI_BONUS_STANDARD' => 'CB.ORI_BONUS_STANDARD',
- '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',
- ]);
- $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;
- }
- // try {
- $listObj = new PeriodBonusList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth]]);
- // } catch (Exception $e) {
- // LoggerTool::info([$e->getFile(), $e->getLine(), $e->getMessage()]);
- // return $data;
- // }
- return $data;
- }
- /**
- * 团队奖奖金向下追溯
- * @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('请填写期数', 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);
- $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'] = \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',
- 'userIds' => 'UB.USER_ID',
- 'BONUS' => 'BONUS',
- // 'RECONSUME_POINTS' => 'RECONSUME_POINTS',
- 'CASH' => 'CASH',
- 'IS_DEC' => 'UI.IS_DEC',
- 'PERIOD_AT' => 'UI.PERIOD_AT',
- 'MOBILE' => 'UI.MOBILE',
- 'TEL' => 'UI.TEL',
- // 'CF' => 'CF',
- // 'LX' => 'LX',
- // 'HIGHEST_EMP_LV_NAME' => 'UI.HIGHEST_EMP_LV',
- // 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
- ]);
- $condition = $filter['condition'];
- $params = $filter['params'];
- $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',
- 'userIds' => 'UB.USER_ID',
- 'BONUS' => 'BONUS',
- 'IS_DEC' => 'UI.IS_DEC',
- 'PERIOD_AT' => 'UI.PERIOD_AT',
- 'MOBILE' => 'UI.MOBILE',
- 'TEL' => 'UI.TEL',
- // 'CF' => 'CF',
- // 'LX' => 'LX',
- ]);
- $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 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'];
- $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'];
- $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'];
- $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'];
- $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'];
- $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'];
- $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() {
- $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); // 非法请求
- }
- }
- }
|