| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765 |
- <?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\Tool;
- use common\helpers\user\Info;
- use common\helpers\user\Perf;
- use common\models\CalcBonus;
- use common\models\CFLXAudit;
- 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 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\Period;
- use Exception;
- 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 \yii\web\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 \yii\web\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 \yii\web\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 \yii\web\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 \yii\web\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 \yii\web\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 \yii\web\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 \yii\web\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, '奖金流水');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 复消积分流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 会员余额流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 兑换积分流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 现金钱包流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 车房流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 领袖分红流水
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 车房养老奖和领袖分红年度发放审核列表
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 申请发放车房养老奖和领袖分红
- * @return mixed
- * @throws \yii\db\Exception
- * @throws \yii\web\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('非法请求', 400);
- }
- /**
- * 审核车房养老奖和领袖分红
- * @return mixed
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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 \yii\web\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('该期不能查看');
- }
- $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 \yii\web\HttpException
- */
- public function actionNewPeriodBonus() {
- $periodNum = Period::calculatedMaxPeriodNum();
- $data = $this->_periodBonus($periodNum);
- return static::notice($data);
- }
- /**
- * 最新一期奖金导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 获取往期已结算的奖金
- * @return mixed
- * @throws \yii\db\Exception
- * @throws \yii\web\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'=> 'Number of settlement periods']], $data['filterTypes']);
- }
- return static::notice($data);
- }
- /**
- * 往期奖金导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws \yii\web\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]]), '往期奖金');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 获取筛选类型
- * @return mixed
- * @throws \yii\web\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_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;
- }
- $listObj = new PeriodBonusList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth]]);
- return $data;
- }
- /**
- * 团队奖奖金向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 团队奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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('会员不存在', 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 \yii\web\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('会员不存在', 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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 荣衔奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 服务奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 推广奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 消费奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 业绩奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 共享奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 管理奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 荣衔奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 服务奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 推广奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 消费奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 业绩奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 共享奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 管理奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 复销奖向下追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 复销奖向上追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 核算会员区域津贴
- * @return mixed
- * @throws \yii\db\Exception
- * @throws \yii\web\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('会员不存在', 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 \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 补发区域津贴
- * @return mixed
- * @throws \yii\db\Exception
- * @throws \yii\web\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('非法请求', 400);
- }
- /**
- * 补发审核表
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 审核补发区域津贴
- * @return mixed
- * @throws \yii\db\Exception
- * @throws \yii\web\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 \yii\web\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 \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 报单中心店补/补贴追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 报单中心货补追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 区域业绩提成追溯
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 业绩单
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 月积分
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 月业绩
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 期业绩
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 达标业绩
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- /**
- * 会员实时业绩
- * @return mixed
- * @throws \yii\web\HttpException
- */
- public function actionRealTimePerf() {
- $userName = Yii::$app->request->get('userName');
- if (!$userId = Info::getUserIdByUserName($userName)) {
- return static::notice('会员不存在', 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 \yii\web\HttpException
- */
- public function actionYcPerf() {
- $userName = Yii::$app->request->get('userName');
- if (!$userId = Info::getUserIdByUserName($userName)) {
- return static::notice('会员不存在', 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 \yii\web\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 \yii\web\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('导出开始,请到文件管理-导出文件查看');
- }
- }
|