BonusController.php 105 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/2/24
  6. * Time: 下午12:48
  7. */
  8. namespace backendApi\modules\v1\controllers;
  9. use backendApi\modules\v1\models\Admin;
  10. use backendApi\modules\v1\models\exportForms\BonusExportForm;
  11. use backendApi\modules\v1\models\lists\bonus\BalanceList;
  12. use backendApi\modules\v1\models\lists\bonus\FlowBalanceList;
  13. use backendApi\modules\v1\models\lists\bonus\FlowBonusList;
  14. use backendApi\modules\v1\models\lists\bonus\FlowExchangePointsList;
  15. use backendApi\modules\v1\models\lists\bonus\FlowReconsumePointsList;
  16. use backendApi\modules\v1\models\lists\bonus\FlowWalletList;
  17. use backendApi\modules\v1\models\lists\bonus\PerfMonthList;
  18. use backendApi\modules\v1\models\lists\bonus\PerfOrderList;
  19. use backendApi\modules\v1\models\lists\bonus\PerfPeriodList;
  20. use backendApi\modules\v1\models\lists\bonus\PerfStandardList;
  21. use backendApi\modules\v1\models\lists\bonus\PeriodBonusList;
  22. use backendApi\modules\v1\models\lists\bonus\ScoreMonthList;
  23. use backendApi\modules\v1\models\lists\bonus\TraceDownBdList;
  24. use backendApi\modules\v1\models\lists\bonus\TraceDownGlList;
  25. use backendApi\modules\v1\models\lists\bonus\TraceDownGxList;
  26. use backendApi\modules\v1\models\lists\bonus\TraceDownQyList;
  27. use backendApi\modules\v1\models\lists\bonus\TraceDownTgList;
  28. use backendApi\modules\v1\models\lists\bonus\TraceDownXfList;
  29. use backendApi\modules\v1\models\lists\bonus\TraceDownYcList;
  30. use backendApi\modules\v1\models\lists\bonus\TraceDownYjList;
  31. use backendApi\modules\v1\models\lists\bonus\TraceUpBdList;
  32. use backendApi\modules\v1\models\lists\bonus\TraceUpGlList;
  33. use backendApi\modules\v1\models\lists\bonus\TraceUpGxList;
  34. use backendApi\modules\v1\models\lists\bonus\TraceUpQyList;
  35. use backendApi\modules\v1\models\lists\bonus\TraceUpTgList;
  36. use backendApi\modules\v1\models\lists\bonus\TraceUpXfList;
  37. use backendApi\modules\v1\models\lists\bonus\TraceUpYcList;
  38. use backendApi\modules\v1\models\lists\bonus\TraceUpYjList;
  39. use backendApi\modules\v1\models\lists\bonus\UserPerfList;
  40. use common\helpers\Cache;
  41. use common\helpers\Date;
  42. use common\helpers\LoggerTool;
  43. use common\helpers\Tool;
  44. use common\helpers\user\Info;
  45. use common\helpers\user\Perf;
  46. use common\models\CalcBonus;
  47. use common\models\CFLXAudit;
  48. use common\models\forms\PerfAdjustmentForm;
  49. use common\models\forms\ResendQYForm;
  50. use common\models\forms\SendCFAndLXForm;
  51. use common\models\PerfMonth;
  52. use common\models\PerfOrder;
  53. use common\models\PerfPeriod;
  54. use common\models\ResendQYAudit;
  55. use common\models\User;
  56. use common\models\UserInfo;
  57. use common\models\UserNetwork;
  58. use common\models\UserPerf;
  59. use common\models\UserPerfAdjustment;
  60. use Yii;
  61. use common\helpers\Form;
  62. use common\models\Config;
  63. use common\models\FlowBonus;
  64. use common\models\FlowExchangePoints;
  65. use common\models\forms\PeriodForm;
  66. use common\models\forms\UserBonusForm;
  67. use common\models\Period;
  68. use Exception;
  69. use yii\web\HttpException;
  70. class BonusController extends BaseController {
  71. public $modelClass = FlowBonus::class;
  72. public function behaviors() {
  73. return parent::behaviors();
  74. }
  75. /**
  76. * 期数列表
  77. * @return mixed
  78. * @throws \yii\base\InvalidConfigException
  79. * @throws \yii\httpclient\Exception
  80. * @throws HttpException
  81. */
  82. public function actionPeriod() {
  83. $filter = $this->filterCondition([
  84. 'periodNum' => 'PERIOD_NUM',
  85. 'year' => 'CALC_YEAR',
  86. 'month' => 'CALC_MONTH',
  87. 'startTime' => 'START_TIME',
  88. 'endTime' => 'END_TIME',
  89. 'closedAt' => 'CLOSED_AT',
  90. 'perfStartedAt' => 'PERF_STARTED_AT',
  91. 'perfedAt' => 'PERFED_AT',
  92. 'calStartedAt' => 'CALCULATE_STARTED_AT',
  93. 'calculatedAt' => 'CALCULATED_AT',
  94. 'sendStartedAt' => 'SEND_STARTED_AT',
  95. 'sentAt' => 'SENT_AT',
  96. ]);
  97. $condition = $filter['condition'];
  98. $params = $filter['params'];
  99. $periodObj = Period::instance();
  100. $nowPeriodNum = $periodObj->getNowPeriodNum();
  101. $condition .= ' AND PERIOD_NUM<=:PERIOD_NUM AND STATUS=1';
  102. $params[':PERIOD_NUM'] = $nowPeriodNum;
  103. $data = Period::lists($condition, $params, ['orderBy' => 'PERIOD_NUM DESC']);
  104. foreach ($data['list'] as $key => $value) {
  105. // 是否可结算
  106. $data['list'][$key]['IS_CAN_CALC'] = $periodObj->isCanCalc($value['PERIOD_NUM']);
  107. // 是否可挂网
  108. $data['list'][$key]['IS_CAN_SENT'] = $periodObj->isCanSend($value['PERIOD_NUM']);
  109. // 操作数据按钮是否可用
  110. $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']);
  111. }
  112. return static::notice($data);
  113. }
  114. /**
  115. * 结算
  116. * @return mixed
  117. * @throws HttpException
  118. */
  119. public function actionCalcPeriod() {
  120. $periodNum = \Yii::$app->request->get('periodNum');
  121. if (!$periodNum) {
  122. return static::notice('期数不存在', 400);
  123. }
  124. $formModel = new PeriodForm();
  125. $formModel->scenario = 'calc';
  126. if ($formModel->load(Yii::$app->request->get(), '') && $formModel->calcWebToAsync()) {
  127. return static::notice('结算已开始处理,请等待');
  128. } else {
  129. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  130. }
  131. }
  132. /**
  133. * 挂网
  134. * @return mixed
  135. * @throws HttpException
  136. */
  137. public function actionSendPeriod() {
  138. $periodNum = \Yii::$app->request->get('periodNum');
  139. if (!$periodNum) {
  140. return static::notice('期数不存在', 400);
  141. }
  142. $formModel = new PeriodForm();
  143. $formModel->scenario = 'send';
  144. if ($formModel->load(Yii::$app->request->get(), '') && $formModel->sendWebToAsync()) {
  145. // Log::adminHandle('第' . $periodNum . '期挂网');
  146. return static::notice('挂网已开始处理,请等待');
  147. } else {
  148. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  149. }
  150. }
  151. /**
  152. * 查看业绩
  153. * @return mixed
  154. * @throws HttpException
  155. */
  156. public function actionPerf() {
  157. // 获取当前年月
  158. $period = Period::instance();
  159. $yearMonth = $period->getNowYearMonth();
  160. $yearMonth = Yii::$app->request->get('yearMonth', $yearMonth);
  161. //$filter = $this->filterCondition(Perf::tableName(), ['periodNum'=>'P.PERIOD_NUM', 'userName'=>'UI.USER_NAME']);
  162. $condition = '';
  163. $params = [];
  164. $data = PerfPeriod::lists($condition, $params, [
  165. 'select' => 'P.*, UI.USER_NAME',
  166. 'yearMonth' => $yearMonth,
  167. 'from' => PerfPeriod::tableName() . ' AS P',
  168. 'join' => [
  169. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'P.USER_ID=UI.USER_ID']
  170. ],
  171. 'orderBy' => 'P.PERIOD_NUM DESC',
  172. ]);
  173. $data['request'] = [];
  174. $data['request']['yearMonth'] = $yearMonth;
  175. return static::notice($data);
  176. }
  177. /**
  178. * 奖金流水
  179. * @return mixed
  180. * @throws \yii\base\Exception
  181. * @throws HttpException
  182. */
  183. public function actionFlowBonus() {
  184. $filter = $this->filterCondition([
  185. 'USER_NAME' => 'U.USER_NAME',
  186. 'REAL_NAME' => 'U.REAL_NAME',
  187. 'IS_DEC' => 'U.IS_DEC',
  188. 'userIds' => 'USER_ID',
  189. 'CREATED_AT' => 'FB.CREATED_AT',
  190. 'PERIOD_NUM' => 'PERIOD_NUM',
  191. 'CALC_MONTH' => 'CALC_MONTH',
  192. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  193. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  194. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  195. 'AMOUNT' => 'AMOUNT',
  196. 'TOTAL' => 'TOTAL',
  197. 'ADMIN_NAME' => 'ADMIN_NAME',
  198. 'REMARK' => 'REMARK',
  199. 'TRANSFER_SN' => 'TRANSFER_SN',
  200. ]);
  201. $condition = $filter['condition'];
  202. $params = $filter['params'];
  203. $listObj = new FlowBonusList();
  204. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  205. return static::notice($data);
  206. }
  207. /**
  208. * 奖金流水
  209. * @return mixed
  210. * @throws \yii\db\Exception
  211. * @throws HttpException
  212. */
  213. public function actionFlowBonusExport() {
  214. $filter = $this->filterCondition([
  215. 'USER_NAME' => 'U.USER_NAME',
  216. 'REAL_NAME' => 'U.REAL_NAME',
  217. 'IS_DEC' => 'U.IS_DEC',
  218. 'userIds' => 'USER_ID',
  219. 'CREATED_AT' => 'FB.CREATED_AT',
  220. 'PERIOD_NUM' => 'PERIOD_NUM',
  221. 'CALC_MONTH' => 'CALC_MONTH',
  222. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  223. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  224. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  225. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  226. 'AMOUNT' => 'AMOUNT',
  227. 'TOTAL' => 'TOTAL',
  228. 'ADMIN_NAME' => 'ADMIN_NAME',
  229. 'REMARK' => 'REMARK',
  230. 'TRANSFER_SN' => 'TRANSFER_SN',
  231. ]);
  232. $form = new BonusExportForm();
  233. $result = $form->run($filter, 'Bonus_Flow'); // 奖金流水
  234. if (!$result) {
  235. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  236. }
  237. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  238. }
  239. /**
  240. * 复消积分流水
  241. * @return mixed
  242. * @throws \yii\base\Exception
  243. * @throws HttpException
  244. */
  245. public function actionFlowRp() {
  246. $filter = $this->filterCondition([
  247. 'userIds' => 'USER_ID',
  248. 'CREATED_AT' => 'CREATED_AT',
  249. 'PERIOD_NUM' => 'PERIOD_NUM',
  250. 'CALC_MONTH' => 'CALC_MONTH',
  251. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  252. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  253. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  254. 'AMOUNT' => 'AMOUNT',
  255. 'TOTAL' => 'TOTAL',
  256. 'ADMIN_NAME' => 'ADMIN_NAME',
  257. 'REMARK' => 'REMARK',
  258. ]);
  259. $condition = $filter['condition'];
  260. $params = $filter['params'];
  261. $listObj = new FlowReconsumePointsList();
  262. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  263. return static::notice($data);
  264. }
  265. /**
  266. * 复消积分流水导出
  267. * @return mixed
  268. * @throws \yii\db\Exception
  269. * @throws HttpException
  270. */
  271. public function actionFlowRpExport() {
  272. $filter = $this->filterCondition([
  273. 'userIds' => 'USER_ID',
  274. 'CREATED_AT' => 'CREATED_AT',
  275. 'PERIOD_NUM' => 'PERIOD_NUM',
  276. 'CALC_MONTH' => 'CALC_MONTH',
  277. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  278. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  279. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  280. 'AMOUNT' => 'AMOUNT',
  281. 'TOTAL' => 'TOTAL',
  282. 'ADMIN_NAME' => 'ADMIN_NAME',
  283. 'REMARK' => 'REMARK',
  284. ]);
  285. $form = new BonusExportForm();
  286. $result = $form->run($filter, '复消积分流水');
  287. if (!$result) {
  288. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  289. }
  290. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  291. }
  292. /**
  293. * 会员余额流水
  294. * @return mixed
  295. * @throws \yii\base\Exception
  296. * @throws HttpException
  297. */
  298. public function actionFlowBalance() {
  299. $filter = $this->filterCondition([
  300. 'USER_NAME' => 'USER_NAME',
  301. 'REAL_NAME' => 'REAL_NAME',
  302. 'CALC_MONTH' => 'CALC_MONTH',
  303. 'PERIOD_NUM' => 'PERIOD_NUM',
  304. 'TRANSFER_SN' => 'TRANSFER_SN',
  305. 'CREATED_AT' => 'FW.CREATED_AT',
  306. 'AMOUNT' => 'AMOUNT',
  307. 'TOTAL' => 'TOTAL',
  308. 'REMARK' => 'REMARK',
  309. ]);
  310. $condition = $filter['condition'];
  311. $params = $filter['params'];
  312. $listObj = new FlowBalanceList();
  313. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  314. return static::notice($data);
  315. }
  316. /**
  317. * 会员余额流水导出
  318. * @return mixed
  319. * @throws \yii\db\Exception
  320. * @throws HttpException
  321. */
  322. public function actionFlowBalanceExport() {
  323. $filter = $this->filterCondition([
  324. 'USER_NAME' => 'USER_NAME',
  325. 'REAL_NAME' => 'REAL_NAME',
  326. 'CALC_MONTH' => 'CALC_MONTH',
  327. 'PERIOD_NUM' => 'PERIOD_NUM',
  328. 'TRANSFER_SN' => 'TRANSFER_SN',
  329. 'CREATED_AT' => 'FW.CREATED_AT',
  330. 'AMOUNT' => 'AMOUNT',
  331. 'TOTAL' => 'TOTAL',
  332. 'REMARK' => 'REMARK',
  333. ]);
  334. $form = new BonusExportForm();
  335. $result = $form->run($filter, '会员余额流水');
  336. if (!$result) {
  337. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  338. }
  339. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  340. }
  341. /**
  342. * 兑换积分流水
  343. * @return mixed
  344. * @throws \yii\base\Exception
  345. * @throws HttpException
  346. */
  347. public function actionFlowExchange() {
  348. $filter = $this->filterCondition([
  349. 'userIds' => 'USER_ID',
  350. 'CREATED_AT' => 'CREATED_AT',
  351. 'PERIOD_NUM' => 'PERIOD_NUM',
  352. 'CALC_MONTH' => 'CALC_MONTH',
  353. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  354. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  355. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  356. 'AMOUNT' => 'AMOUNT',
  357. 'TOTAL' => 'TOTAL',
  358. 'ADMIN_NAME' => 'ADMIN_NAME',
  359. 'REMARK' => 'REMARK',
  360. ]);
  361. $condition = $filter['condition'];
  362. $params = $filter['params'];
  363. $listObj = new FlowExchangePointsList();
  364. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  365. return static::notice($data);
  366. }
  367. /**
  368. * 兑换积分流水导出
  369. * @return mixed
  370. * @throws \yii\db\Exception
  371. * @throws HttpException
  372. */
  373. public function actionFlowExchangeExport() {
  374. $filter = $this->filterCondition([
  375. 'userIds' => 'USER_ID',
  376. 'CREATED_AT' => 'CREATED_AT',
  377. 'PERIOD_NUM' => 'PERIOD_NUM',
  378. 'CALC_MONTH' => 'CALC_MONTH',
  379. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  380. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  381. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  382. 'AMOUNT' => 'AMOUNT',
  383. 'TOTAL' => 'TOTAL',
  384. 'ADMIN_NAME' => 'ADMIN_NAME',
  385. 'REMARK' => 'REMARK',
  386. ]);
  387. $form = new BonusExportForm();
  388. $result = $form->run($filter, '兑换积分流水');
  389. if (!$result) {
  390. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  391. }
  392. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  393. }
  394. /**
  395. * 现金钱包流水
  396. * @return mixed
  397. * @throws \yii\base\Exception
  398. * @throws HttpException
  399. */
  400. public function actionFlowWallet() {
  401. $filter = $this->filterCondition([
  402. 'USER_NAME' => 'U.USER_NAME',
  403. 'REAL_NAME' => 'U.REAL_NAME',
  404. 'IS_DEC' => 'U.IS_DEC',
  405. 'userIds' => 'USER_ID',
  406. 'CREATED_AT' => 'CREATED_AT',
  407. 'PERIOD_NUM' => 'PERIOD_NUM',
  408. 'CALC_MONTH' => 'CALC_MONTH',
  409. 'AMOUNT' => 'AMOUNT',
  410. 'TOTAL' => 'TOTAL',
  411. 'ADMIN_NAME' => 'ADMIN_NAME',
  412. 'REMARK' => 'REMARK',
  413. ]);
  414. $condition = $filter['condition'];
  415. $params = $filter['params'];
  416. $listObj = new FlowWalletList();
  417. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  418. return static::notice($data);
  419. }
  420. /**
  421. * 现金钱包流水导出
  422. * @return mixed
  423. * @throws \yii\db\Exception
  424. * @throws HttpException
  425. */
  426. public function actionFlowWalletExport() {
  427. $filter = $this->filterCondition([
  428. 'USER_NAME' => 'U.USER_NAME',
  429. 'REAL_NAME' => 'U.REAL_NAME',
  430. 'IS_DEC' => 'U.IS_DEC',
  431. 'userIds' => 'USER_ID',
  432. 'CREATED_AT' => 'CREATED_AT',
  433. 'PERIOD_NUM' => 'PERIOD_NUM',
  434. 'CALC_MONTH' => 'CALC_MONTH',
  435. 'AMOUNT' => 'AMOUNT',
  436. 'TOTAL' => 'TOTAL',
  437. 'ADMIN_NAME' => 'ADMIN_NAME',
  438. 'REMARK' => 'REMARK',
  439. ]);
  440. $form = new BonusExportForm();
  441. $result = $form->run($filter, '现金钱包流水');
  442. if (!$result) {
  443. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  444. }
  445. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  446. }
  447. /**
  448. * 车房流水
  449. * @return mixed
  450. * @throws \yii\base\Exception
  451. * @throws HttpException
  452. */
  453. public function actionFlowCf() {
  454. $filter = $this->filterCondition([
  455. 'userIds' => 'USER_ID',
  456. 'CREATED_AT' => 'CREATED_AT',
  457. 'PERIOD_NUM' => 'PERIOD_NUM',
  458. 'CALC_MONTH' => 'CALC_MONTH',
  459. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  460. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  461. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  462. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  463. 'AMOUNT' => 'AMOUNT',
  464. 'TOTAL' => 'TOTAL',
  465. 'ADMIN_NAME' => 'ADMIN_NAME',
  466. 'REMARK' => 'REMARK',
  467. ]);
  468. $condition = $filter['condition'];
  469. $params = $filter['params'];
  470. $listObj = new FlowCfList();
  471. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  472. return static::notice($data);
  473. }
  474. /**
  475. * 车房养老奖流水导出
  476. * @return mixed
  477. * @throws \yii\db\Exception
  478. * @throws HttpException
  479. */
  480. public function actionFlowCfExport() {
  481. $filter = $this->filterCondition([
  482. 'userIds' => 'USER_ID',
  483. 'CREATED_AT' => 'CREATED_AT',
  484. 'PERIOD_NUM' => 'PERIOD_NUM',
  485. 'CALC_MONTH' => 'CALC_MONTH',
  486. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  487. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  488. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  489. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  490. 'AMOUNT' => 'AMOUNT',
  491. 'TOTAL' => 'TOTAL',
  492. 'ADMIN_NAME' => 'ADMIN_NAME',
  493. 'REMARK' => 'REMARK',
  494. ]);
  495. $form = new BonusExportForm();
  496. $result = $form->run($filter, '车房养老奖流水');
  497. if (!$result) {
  498. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  499. }
  500. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  501. }
  502. /**
  503. * 领袖分红流水
  504. * @return mixed
  505. * @throws \yii\base\Exception
  506. * @throws HttpException
  507. */
  508. public function actionFlowLx() {
  509. $filter = $this->filterCondition([
  510. 'userIds' => 'USER_ID',
  511. 'CREATED_AT' => 'CREATED_AT',
  512. 'PERIOD_NUM' => 'PERIOD_NUM',
  513. 'CALC_MONTH' => 'CALC_MONTH',
  514. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  515. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  516. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  517. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  518. 'AMOUNT' => 'AMOUNT',
  519. 'TOTAL' => 'TOTAL',
  520. 'ADMIN_NAME' => 'ADMIN_NAME',
  521. 'REMARK' => 'REMARK',
  522. ]);
  523. $condition = $filter['condition'];
  524. $params = $filter['params'];
  525. $listObj = new FlowLxList();
  526. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  527. return static::notice($data);
  528. }
  529. /**
  530. * 导出
  531. * @return mixed
  532. * @throws \yii\db\Exception
  533. * @throws HttpException
  534. */
  535. public function actionFlowLxExport() {
  536. $filter = $this->filterCondition([
  537. 'userIds' => 'USER_ID',
  538. 'CREATED_AT' => 'CREATED_AT',
  539. 'PERIOD_NUM' => 'PERIOD_NUM',
  540. 'CALC_MONTH' => 'CALC_MONTH',
  541. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  542. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  543. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  544. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  545. 'AMOUNT' => 'AMOUNT',
  546. 'TOTAL' => 'TOTAL',
  547. 'ADMIN_NAME' => 'ADMIN_NAME',
  548. 'REMARK' => 'REMARK',
  549. ]);
  550. $form = new BonusExportForm();
  551. $result = $form->run($filter, '领袖分红奖流水');
  552. if (!$result) {
  553. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  554. }
  555. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  556. }
  557. /**
  558. * 车房养老奖和领袖分红年度发放审核列表
  559. * @return mixed
  560. * @throws \yii\base\Exception
  561. * @throws HttpException
  562. */
  563. public function actionCfLxAuditList() {
  564. $filter = $this->filterCondition([
  565. 'userIds' => 'CFLXA.USER_ID',
  566. 'CF' => 'CFLXA.CF',
  567. 'LX' => 'CFLXA.LX',
  568. 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  569. 'CREATED_AT' => 'CFLXA.CREATED_AT',
  570. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  571. 'AUDITED_AT' => 'CFLXA.AUDITED_AT',
  572. 'CREATE_REMARK' => 'CFLXA.CREATE_REMARK',
  573. 'filterStatus' => 'CFLXA.AUDIT_STATUS',
  574. ]);
  575. $condition = $filter['condition'];
  576. $params = $filter['params'];
  577. $listObj = new CfLxAuditList();
  578. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  579. return static::notice($data);
  580. }
  581. /**
  582. * 车房养老奖和领袖分红年度发放审核导出
  583. * @return mixed
  584. * @throws \yii\db\Exception
  585. * @throws HttpException
  586. */
  587. public function actionCfLxAuditExport() {
  588. $filter = $this->filterCondition([
  589. 'userIds' => 'CFLXA.USER_ID',
  590. 'CF' => 'CFLXA.CF',
  591. 'LX' => 'CFLXA.LX',
  592. 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  593. 'CREATED_AT' => 'CFLXA.CREATED_AT',
  594. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  595. 'AUDITED_AT' => 'CFLXA.AUDITED_AT',
  596. 'CREATE_REMARK' => 'CFLXA.CREATE_REMARK',
  597. 'filterStatus' => 'CFLXA.AUDIT_STATUS',
  598. ]);
  599. $form = new BonusExportForm();
  600. $result = $form->run($filter, '年度奖金发放审核');
  601. if (!$result) {
  602. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  603. }
  604. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  605. }
  606. /**
  607. * 申请发放车房养老奖和领袖分红
  608. * @return mixed
  609. * @throws \yii\db\Exception
  610. * @throws HttpException
  611. */
  612. public function actionCfLxApply() {
  613. if (Yii::$app->request->isPost) {
  614. $formModel = new SendCFAndLXForm();
  615. $formModel->scenario = 'apply';
  616. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->apply()) {
  617. if(!empty($result['logs'])){
  618. return static::notice('申请成功,请在年度奖管理中审核');
  619. }else{
  620. return static::notice('申请失败,无符合发放条件会员',400);
  621. }
  622. } else {
  623. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  624. }
  625. }
  626. return static::notice('Illegal request', 400); // 非法请求
  627. }
  628. /**
  629. * 审核车房养老奖和领袖分红
  630. * @return mixed
  631. * @throws \yii\db\Exception
  632. * @throws HttpException
  633. */
  634. public function actionCfLxAudit() {
  635. $formModel = new SendCFAndLXForm();
  636. $formModel->scenario = 'audit';
  637. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  638. return static::notice('审核年度奖申请完成');
  639. }
  640. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  641. }
  642. /**
  643. * 删除车房领袖审核信息
  644. * @return mixed
  645. * @throws \yii\db\Exception
  646. * @throws HttpException
  647. */
  648. public function actionCfLxAuditDelete() {
  649. $sendCFAndLXForm = new SendCFAndLXForm();
  650. $result = static::delete(CFLXAudit::class, function ($selected) use ($sendCFAndLXForm) {
  651. $sendCFAndLXForm->beforeDelete($selected);
  652. // Log::adminHandle('删除审核会员余额信息');
  653. }, function ($selected) use ($sendCFAndLXForm) {
  654. $sendCFAndLXForm->delete($selected);
  655. // Log::adminHandle('删除审核会员余额信息');
  656. }, true);
  657. return $result;
  658. }
  659. /**
  660. * 查看所传期数的各项奖金
  661. * @return mixed
  662. * @throws \yii\db\Exception
  663. * @throws HttpException
  664. */
  665. public function actionPeriodDetail() {
  666. $periodNum = \Yii::$app->request->get('periodNum');
  667. $period = Period::instance();
  668. $periodInfo = $period->setPeriodNum($periodNum);
  669. $yearMonth = $period->getYearMonth($periodNum);
  670. // $filter = $this->filterCondition('UT', [
  671. // 'userName' => 'UI.USER_NAME',
  672. // ]);
  673. $condition = '';
  674. $params = [];
  675. $condition .= ' AND C.PERIOD_NUM=:PERIOD_NUM';
  676. $params[':PERIOD_NUM'] = $periodNum;
  677. if (!$period->isClosed($periodNum)) {
  678. return static::notice('Cannot view this period'); // 该期不能查看
  679. }
  680. $data = CalcBonus::lists($condition, $params, [
  681. 'yearMonth' => $yearMonth,
  682. 'select' => 'C.*,UI.USER_NAME',
  683. 'from' => CalcBonus::tableName() . ' AS C',
  684. 'join' => [
  685. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'C.USER_ID=UI.USER_ID'],
  686. ],
  687. 'orderBy' => 'C.CREATED_AT DESC',
  688. ]);
  689. $data['periodInfo'] = $periodInfo;
  690. return static::notice($data);
  691. }
  692. /**
  693. * 获取最新一期结算的奖金
  694. * @return mixed
  695. * @throws \yii\base\Exception
  696. * @throws \yii\db\Exception
  697. * @throws HttpException
  698. */
  699. public function actionNewPeriodBonus() {
  700. $periodNum = Period::calculatedMaxPeriodNum();
  701. $data = $this->_periodBonus($periodNum);
  702. return static::notice($data);
  703. }
  704. /**
  705. * 最新一期奖金导出
  706. * @return mixed
  707. * @throws \yii\db\Exception
  708. * @throws HttpException
  709. */
  710. public function actionNewPeriodBonusExport() {
  711. $filter = $this->filterCondition([
  712. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  713. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  714. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  715. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  716. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  717. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  718. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  719. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  720. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  721. 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  722. 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  723. 'BONUS_BD' => 'CB.BONUS_BD',
  724. 'BONUS_TG' => 'CB.BONUS_TG',
  725. 'BONUS_YJ' => 'CB.BONUS_YJ',
  726. 'BONUS_GX' => 'CB.BONUS_GX',
  727. // 'BONUS_GL' => 'CB.BONUS_BS',
  728. 'BONUS_GL' => 'CB.BONUS_GL',
  729. 'BONUS_QY' => 'CB.BONUS_QY',
  730. 'BONUS_YC' => 'CB.BONUS_YC',
  731. 'PV_1L' => 'CB.PV_1L',
  732. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  733. 'PV_2L' => 'CB.PV_2L',
  734. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  735. 'PV_3L' => 'CB.PV_3L',
  736. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  737. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  738. 'CALC_MONTH' => 'CB.CALC_MONTH',
  739. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  740. ]);
  741. $periodNum = Period::calculatedMaxPeriodNum();
  742. $period = Period::instance();
  743. $yearMonth = $period->getYearMonth($periodNum);
  744. $filter['condition'] .= ' AND PERIOD_NUM=:PERIOD_NUM';
  745. $filter['params'][':PERIOD_NUM'] = $periodNum;
  746. $form = new BonusExportForm();
  747. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth]]), '最新奖金');
  748. if (!$result) {
  749. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  750. }
  751. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  752. }
  753. /**
  754. * 获取往期已结算的奖金
  755. * @return mixed
  756. * @throws \yii\db\Exception
  757. * @throws HttpException
  758. */
  759. public function actionOtherPeriodBonus() {
  760. $periodNumRequest = \Yii::$app->request->get('periodNum');
  761. if(!$periodNumRequest){
  762. $periodNum = Period::calculatedMaxPeriodNum();
  763. //return static::notice('请填写期数',400);
  764. }else{
  765. $periodNum = explode(",", $periodNumRequest)[1];
  766. }
  767. $data = $this->_periodBonus($periodNum,false);
  768. if( isset($data['filterTypes']) && is_array($data['filterTypes']) ) {
  769. $data['filterTypes'] = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> \Yii::t('ctx', 'payCycle')]], $data['filterTypes']);
  770. }
  771. return static::notice($data);
  772. }
  773. /**
  774. * 往期奖金导出
  775. * @return mixed
  776. * @throws \yii\db\Exception
  777. * @throws HttpException
  778. */
  779. public function actionOtherPeriodBonusExport() {
  780. $filter = $this->filterCondition([
  781. 'periodNum' => 'CB.PERIOD_NUM',
  782. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  783. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  784. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  785. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  786. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  787. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  788. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  789. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  790. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  791. 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  792. 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  793. 'BONUS_BD' => 'CB.BONUS_BD',
  794. 'BONUS_TG' => 'CB.BONUS_TG',
  795. 'BONUS_YJ' => 'CB.BONUS_YJ',
  796. 'BONUS_GX' => 'CB.BONUS_GX',
  797. 'BONUS_GL' => 'CB.BONUS_GL',
  798. // 'BONUS_GL' => 'CB.BONUS_BS',
  799. 'BONUS_QY' => 'CB.BONUS_QY',
  800. 'BONUS_YC' => 'CB.BONUS_YC',
  801. 'PV_1L' => 'CB.PV_1L',
  802. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  803. 'PV_2L' => 'CB.PV_2L',
  804. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  805. 'PV_3L' => 'CB.PV_3L',
  806. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  807. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  808. 'CALC_MONTH' => 'CB.CALC_MONTH',
  809. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  810. ]);
  811. $periodNumRequest = \Yii::$app->request->get('periodNum');
  812. if(!$periodNumRequest){
  813. $periodNum = Period::calculatedMaxPeriodNum();
  814. }else{
  815. $periodNum = explode(",", $periodNumRequest)[1];
  816. }
  817. // if(!isset($filter['params'][':PERIODNUM'])){
  818. // return static::notice('请填写期数',400);
  819. // }
  820. // $periodNum = $filter['params'][':PERIODNUM'];
  821. $period = Period::instance();
  822. $yearMonth = $period->getYearMonth($periodNum);
  823. // $filter['condition'] .= ' AND CB.PERIOD_NUM=:PERIOD_NUM';
  824. // $filter['params'][':PERIOD_NUM'] = $periodNum;
  825. $form = new BonusExportForm();
  826. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth]]), 'Member Bonus'); // 往期奖金
  827. if (!$result) {
  828. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  829. }
  830. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  831. }
  832. /**
  833. * 获取筛选类型
  834. * @return mixed
  835. * @throws HttpException
  836. */
  837. public function actionOtherPeriodBonusFilterTypes(){
  838. $listObj = new PeriodBonusList();
  839. $filterTypes = $listObj->getFilterTypes();
  840. $filterTypes = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> \Yii::t('ctx', 'payCycle')]], $filterTypes);
  841. return static::notice($filterTypes);
  842. }
  843. /**
  844. * 期数对应的奖金
  845. * @param $periodNum
  846. * @param $periodFilter
  847. * @return array
  848. * @throws \yii\base\Exception
  849. * @throws \yii\db\Exception
  850. */
  851. private function _periodBonus($periodNum,$periodFilter = true) {
  852. $filter = $this->filterCondition([
  853. 'periodNum' => 'CB.PERIOD_NUM',
  854. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  855. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  856. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  857. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  858. 'LAST_CROWN_LV_NAME' => 'CB.LAST_CROWN_LV',
  859. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  860. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  861. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  862. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  863. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  864. // 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  865. // 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  866. 'BONUS_BD' => 'CB.BONUS_BD',
  867. 'BONUS_TG' => 'CB.BONUS_TG',
  868. // 'BONUS_XF' => 'CB.BONUS_XF',
  869. // 'BONUS_YJ' => 'CB.BONUS_YJ',
  870. // 'BONUS_GX' => 'CB.BONUS_GX',
  871. // 'BONUS_GL' => 'CB.BONUS_GL',
  872. // 'BONUS_GL' => 'CB.BONUS_BS',
  873. 'BONUS_QY' => 'CB.BONUS_QY',
  874. // 'BONUS_YC' => 'CB.BONUS_YC',
  875. // 'ORI_BONUS_STANDARD' => 'CB.ORI_BONUS_STANDARD',
  876. 'PV_1L' => 'CB.PV_1L',
  877. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  878. 'PV_2L' => 'CB.PV_2L',
  879. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  880. // 'PV_3L' => 'CB.PV_3L',
  881. // 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  882. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  883. 'CALC_MONTH' => 'CB.CALC_MONTH',
  884. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  885. ]);
  886. $period = Period::instance();
  887. $yearMonth = $period->getYearMonth($periodNum);
  888. $condition = $filter['condition'];
  889. $params = $filter['params'];
  890. if($periodFilter){
  891. $condition .= ' AND CB.PERIOD_NUM=:PERIOD_NUM';
  892. $params[':PERIOD_NUM'] = $periodNum;
  893. }
  894. // try {
  895. $listObj = new PeriodBonusList();
  896. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth]]);
  897. // } catch (Exception $e) {
  898. // LoggerTool::info([$e->getFile(), $e->getLine(), $e->getMessage()]);
  899. // return $data;
  900. // }
  901. return $data;
  902. }
  903. /**
  904. * 团队奖奖金向下追溯
  905. * @return mixed
  906. * @throws \yii\base\Exception
  907. * @throws \yii\db\Exception
  908. * @throws HttpException
  909. */
  910. public function actionTraceDownQy() {
  911. $periodNum = Yii::$app->request->get('periodNum');
  912. if (!$periodNum) return static::notice(\Yii::t('ctx', 'requirePeriods'), 400);
  913. $userName = Yii::$app->request->get('userName');
  914. if (!$userName) return static::notice(\Yii::t('ctx', 'requireMemberNumber'), 400);
  915. $period = Period::instance();
  916. if (!$period->isCalculated($periodNum)) {
  917. return static::notice([]);
  918. }
  919. $yearMonth = $period->getYearMonth($periodNum);
  920. $filter = $this->filterCondition([
  921. 'decType' => 'PO.DEC_TYPE',
  922. 'periodNum' => 'PO.PERIOD_NUM',
  923. ]);
  924. $qyFilter = $this->_qyFilterCondition($filter['request']);
  925. $filter = array_merge($filter, $qyFilter);
  926. $condition = $filter['condition'];
  927. $params = $filter['params'];
  928. $listObj = new TraceDownQyList();
  929. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  930. return static::notice($data);
  931. }
  932. /**
  933. * 获取
  934. * @param $request
  935. * @return array|string[]
  936. */
  937. private function _qyFilterCondition($request) {
  938. //根据USER_NAME获取USER_ID
  939. $user = User::find()->select('ID')->where('USER_NAME=:USER_NAME', ['USER_NAME'=>$request['userName']])->asArray()->one();
  940. if( !$user ) return [];
  941. //找到这个会员的LOCATION_TAG
  942. $userNetwork = UserNetwork::find()->select(['LOCATION_TAG'])->where('USER_ID=:USER_ID', ['USER_ID'=>$user['ID']])->asArray()->one();
  943. $searchLocationTag = $userNetwork['LOCATION_TAG'];
  944. if( isset($request['location']) && $request['location'] ) {
  945. $searchLocationTag .= $request['location'];
  946. }
  947. return [
  948. 'LOCATION_TAG' => 'LIKE ' . $searchLocationTag . '%'
  949. ];
  950. }
  951. /**
  952. * 团队奖向下追溯导出
  953. * @return mixed
  954. * @throws \yii\db\Exception
  955. * @throws HttpException
  956. */
  957. public function actionTraceDownQyExport() {
  958. $periodNum = Yii::$app->request->get('periodNum');
  959. if (!$periodNum) return static::notice('请填写期数', 400);
  960. $userName = Yii::$app->request->get('userName');
  961. if (!$userName) return static::notice('请填写会员编号', 400);
  962. $period = Period::instance();
  963. if (!$period->isCalculated($periodNum)) {
  964. return static::notice([]);
  965. }
  966. $yearMonth = $period->getYearMonth($periodNum);
  967. $filter = $this->filterCondition([
  968. 'decType' => 'PO.DEC_TYPE',
  969. 'periodNum' => 'PO.PERIOD_NUM',
  970. ]);
  971. $qyFilter = $this->_qyFilterCondition($filter['request']);
  972. $filter = array_merge($filter, $qyFilter);
  973. $form = new BonusExportForm();
  974. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '团队奖向下追溯');
  975. if (!$result) {
  976. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  977. }
  978. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  979. }
  980. /**
  981. * 团队奖向上追溯
  982. * @return mixed
  983. * @throws \yii\base\Exception
  984. * @throws HttpException
  985. */
  986. public function actionTraceUpQy() {
  987. $periodNum = Yii::$app->request->get('periodNum');
  988. if (!$periodNum) return static::notice('请填写期数', 400);
  989. if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
  990. if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('Member does not exist', 400); // 会员不存在
  991. //会员是否有业绩单
  992. if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
  993. return static::notice('该会员本期没有业绩单', 400);
  994. }
  995. $listObj = new TraceUpQyList();
  996. $data = $listObj->getList(['condition'=>'', 'params'=>[], 'others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]);
  997. return static::notice($data);
  998. }
  999. /**
  1000. * 团队奖向上追溯导出
  1001. * @return mixed
  1002. * @throws \yii\db\Exception
  1003. * @throws HttpException
  1004. */
  1005. public function actionTraceUpQyExport() {
  1006. $periodNum = Yii::$app->request->get('periodNum');
  1007. if (!$periodNum) return static::notice('请填写期数', 400);
  1008. if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
  1009. if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('Member does not exist', 400); // 会员不存在
  1010. //会员是否有业绩单
  1011. if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
  1012. return static::notice('该会员本期没有业绩单', 400);
  1013. }
  1014. $form = new BonusExportForm();
  1015. $result = $form->run(array_merge(['condition'=>'', 'params'=>[]], ['others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]), '团队奖向上追溯');
  1016. if (!$result) {
  1017. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1018. }
  1019. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1020. }
  1021. /**
  1022. * 荣衔奖向下追溯
  1023. * @return mixed
  1024. * @throws \yii\base\Exception
  1025. * @throws \yii\db\Exception
  1026. * @throws HttpException
  1027. */
  1028. public function actionTraceDownYc() {
  1029. $periodNum = Yii::$app->request->get('periodNum');
  1030. if (!$periodNum) return static::notice([]);
  1031. $period = Period::instance();
  1032. $yearMonth = $period->getYearMonth($periodNum);
  1033. $filter = $this->filterCondition([
  1034. 'userName' => 'UI.USER_NAME',
  1035. 'periodNum' => 'CBY.PERIOD_NUM',
  1036. ]);
  1037. $condition = $filter['condition'];
  1038. $params = $filter['params'];
  1039. $listObj = new TraceDownYcList();
  1040. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1041. return static::notice($data);
  1042. }
  1043. /**
  1044. * 荣衔奖向下追溯导出
  1045. * @return mixed
  1046. * @throws \yii\db\Exception
  1047. * @throws HttpException
  1048. */
  1049. public function actionTraceDownYcExport() {
  1050. $periodNum = Yii::$app->request->get('periodNum');
  1051. if (!$periodNum) return static::notice([]);
  1052. $period = Period::instance();
  1053. $yearMonth = $period->getYearMonth($periodNum);
  1054. $filter = $this->filterCondition([
  1055. 'userName' => 'UI.USER_NAME',
  1056. 'periodNum' => 'CBY.PERIOD_NUM',
  1057. ]);
  1058. $form = new BonusExportForm();
  1059. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向下追溯');
  1060. if (!$result) {
  1061. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1062. }
  1063. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1064. }
  1065. /**
  1066. * 服务奖向下追溯
  1067. * @return mixed
  1068. * @throws \yii\base\Exception
  1069. * @throws \yii\db\Exception
  1070. * @throws HttpException
  1071. */
  1072. public function actionTraceDownBd() {
  1073. $periodNum = Yii::$app->request->get('periodNum');
  1074. if (!$periodNum) return static::notice([]);
  1075. $period = Period::instance();
  1076. $yearMonth = $period->getYearMonth($periodNum);
  1077. $filter = $this->filterCondition([
  1078. 'userName' => 'UI.USER_NAME',
  1079. 'periodNum' => 'CBB.PERIOD_NUM',
  1080. ]);
  1081. $condition = $filter['condition'];
  1082. $params = $filter['params'];
  1083. $listObj = new TraceDownBdList();
  1084. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1085. return static::notice($data);
  1086. }
  1087. /**
  1088. * 服务奖向下追溯导出
  1089. * @return mixed
  1090. * @throws \yii\db\Exception
  1091. * @throws HttpException
  1092. */
  1093. public function actionTraceDownBdExport() {
  1094. $periodNum = Yii::$app->request->get('periodNum');
  1095. if (!$periodNum) return static::notice([]);
  1096. $period = Period::instance();
  1097. $yearMonth = $period->getYearMonth($periodNum);
  1098. $filter = $this->filterCondition([
  1099. 'userName' => 'UI.USER_NAME',
  1100. 'periodNum' => 'CBB.PERIOD_NUM',
  1101. ]);
  1102. $form = new BonusExportForm();
  1103. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '服务奖向下追溯');
  1104. if (!$result) {
  1105. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1106. }
  1107. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1108. }
  1109. /**
  1110. * 推广奖向下追溯
  1111. * @return mixed
  1112. * @throws \yii\base\Exception
  1113. * @throws \yii\db\Exception
  1114. * @throws HttpException
  1115. */
  1116. public function actionTraceDownTg() {
  1117. $periodNum = Yii::$app->request->get('periodNum');
  1118. if (!$periodNum) return static::notice([]);
  1119. $period = Period::instance();
  1120. $yearMonth = $period->getYearMonth($periodNum);
  1121. $filter = $this->filterCondition([
  1122. 'userName' => 'UI.USER_NAME',
  1123. 'periodNum' => 'CTG.PERIOD_NUM',
  1124. ]);
  1125. $condition = $filter['condition'];
  1126. $params = $filter['params'];
  1127. $listObj = new TraceDownTgList();
  1128. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1129. return static::notice($data);
  1130. }
  1131. /**
  1132. * 推广奖向下追溯导出
  1133. * @return mixed
  1134. * @throws \yii\db\Exception
  1135. * @throws HttpException
  1136. */
  1137. public function actionTraceDownTgExport() {
  1138. $periodNum = Yii::$app->request->get('periodNum');
  1139. if (!$periodNum) return static::notice([]);
  1140. $period = Period::instance();
  1141. $yearMonth = $period->getYearMonth($periodNum);
  1142. $filter = $this->filterCondition([
  1143. 'userName' => 'UI.USER_NAME',
  1144. 'periodNum' => 'CTG.PERIOD_NUM',
  1145. ]);
  1146. $form = new BonusExportForm();
  1147. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '推广奖向下追溯');
  1148. if (!$result) {
  1149. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1150. }
  1151. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1152. }
  1153. /**
  1154. * 消费奖向下追溯
  1155. * @return mixed
  1156. * @throws \yii\base\Exception
  1157. * @throws \yii\db\Exception
  1158. * @throws HttpException
  1159. */
  1160. public function actionTraceDownXf() {
  1161. $periodNum = Yii::$app->request->get('periodNum');
  1162. if (!$periodNum) return static::notice([]);
  1163. $period = Period::instance();
  1164. $yearMonth = $period->getYearMonth($periodNum);
  1165. $filter = $this->filterCondition([
  1166. 'userName' => 'UI.USER_NAME',
  1167. 'periodNum' => 'CXF.PERIOD_NUM',
  1168. ]);
  1169. $condition = $filter['condition'];
  1170. $params = $filter['params'];
  1171. $listObj = new TraceDownXfList();
  1172. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1173. return static::notice($data);
  1174. }
  1175. /**
  1176. * 消费奖向下追溯导出
  1177. * @return mixed
  1178. * @throws \yii\db\Exception
  1179. * @throws HttpException
  1180. */
  1181. public function actionTraceDownXfExport() {
  1182. $periodNum = Yii::$app->request->get('periodNum');
  1183. if (!$periodNum) return static::notice([]);
  1184. $period = Period::instance();
  1185. $yearMonth = $period->getYearMonth($periodNum);
  1186. $filter = $this->filterCondition([
  1187. 'userName' => 'UI.USER_NAME',
  1188. 'periodNum' => 'CXF.PERIOD_NUM',
  1189. ]);
  1190. $form = new BonusExportForm();
  1191. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '推广奖向下追溯');
  1192. if (!$result) {
  1193. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1194. }
  1195. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1196. }
  1197. /**
  1198. * 业绩奖向下追溯
  1199. * @return mixed
  1200. * @throws \yii\base\Exception
  1201. * @throws \yii\db\Exception
  1202. * @throws HttpException
  1203. */
  1204. public function actionTraceDownYj() {
  1205. $periodNum = Yii::$app->request->get('periodNum');
  1206. if (!$periodNum) return static::notice([]);
  1207. $period = Period::instance();
  1208. $yearMonth = $period->getYearMonth($periodNum);
  1209. $filter = $this->filterCondition([
  1210. 'userName' => 'UI.USER_NAME',
  1211. 'periodNum' => 'CYJ.PERIOD_NUM',
  1212. ]);
  1213. $condition = $filter['condition'];
  1214. $params = $filter['params'];
  1215. $listObj = new TraceDownYjList();
  1216. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1217. return static::notice($data);
  1218. }
  1219. /**
  1220. * 业绩奖向下追溯导出
  1221. * @return mixed
  1222. * @throws \yii\db\Exception
  1223. * @throws HttpException
  1224. */
  1225. public function actionTraceDownYjExport() {
  1226. $periodNum = Yii::$app->request->get('periodNum');
  1227. if (!$periodNum) return static::notice([]);
  1228. $period = Period::instance();
  1229. $yearMonth = $period->getYearMonth($periodNum);
  1230. $filter = $this->filterCondition([
  1231. 'userName' => 'UI.USER_NAME',
  1232. 'periodNum' => 'CYJ.PERIOD_NUM',
  1233. ]);
  1234. $form = new BonusExportForm();
  1235. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '业绩奖向下追溯');
  1236. if (!$result) {
  1237. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1238. }
  1239. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1240. }
  1241. /**
  1242. * 共享奖向下追溯
  1243. * @return mixed
  1244. * @throws \yii\base\Exception
  1245. * @throws \yii\db\Exception
  1246. * @throws HttpException
  1247. */
  1248. public function actionTraceDownGx() {
  1249. $periodNum = Yii::$app->request->get('periodNum');
  1250. if (!$periodNum) return static::notice([]);
  1251. $period = Period::instance();
  1252. $yearMonth = $period->getYearMonth($periodNum);
  1253. $filter = $this->filterCondition([
  1254. 'userName' => 'UI.USER_NAME',
  1255. 'periodNum' => 'CGX.PERIOD_NUM',
  1256. ]);
  1257. $condition = $filter['condition'];
  1258. $params = $filter['params'];
  1259. $listObj = new TraceDownGxList();
  1260. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1261. return static::notice($data);
  1262. }
  1263. /**
  1264. * 共享奖向下追溯导出
  1265. * @return mixed
  1266. * @throws \yii\db\Exception
  1267. * @throws HttpException
  1268. */
  1269. public function actionTraceDownGxExport() {
  1270. $periodNum = Yii::$app->request->get('periodNum');
  1271. if (!$periodNum) return static::notice([]);
  1272. $period = Period::instance();
  1273. $yearMonth = $period->getYearMonth($periodNum);
  1274. $filter = $this->filterCondition([
  1275. 'userName' => 'UI.USER_NAME',
  1276. 'periodNum' => 'CGX.PERIOD_NUM',
  1277. ]);
  1278. $form = new BonusExportForm();
  1279. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '共享奖向下追溯');
  1280. if (!$result) {
  1281. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1282. }
  1283. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1284. }
  1285. /**
  1286. * 管理奖向下追溯
  1287. * @return mixed
  1288. * @throws \yii\base\Exception
  1289. * @throws \yii\db\Exception
  1290. * @throws HttpException
  1291. */
  1292. public function actionTraceDownGl() {
  1293. $periodNum = Yii::$app->request->get('periodNum');
  1294. if (!$periodNum) return static::notice([]);
  1295. $period = Period::instance();
  1296. $yearMonth = $period->getYearMonth($periodNum);
  1297. $filter = $this->filterCondition([
  1298. 'userName' => 'UI.USER_NAME',
  1299. 'periodNum' => 'CGL.PERIOD_NUM',
  1300. ]);
  1301. $condition = $filter['condition'];
  1302. $params = $filter['params'];
  1303. $listObj = new TraceDownGlList();
  1304. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1305. return static::notice($data);
  1306. }
  1307. /**
  1308. * 管理奖向下追溯导出
  1309. * @return mixed
  1310. * @throws \yii\db\Exception
  1311. * @throws HttpException
  1312. */
  1313. public function actionTraceDownGlExport() {
  1314. $periodNum = Yii::$app->request->get('periodNum');
  1315. if (!$periodNum) return static::notice([]);
  1316. $period = Period::instance();
  1317. $yearMonth = $period->getYearMonth($periodNum);
  1318. $filter = $this->filterCondition([
  1319. 'userName' => 'UI.USER_NAME',
  1320. 'periodNum' => 'CGL.PERIOD_NUM',
  1321. ]);
  1322. $form = new BonusExportForm();
  1323. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '管理奖向下追溯');
  1324. if (!$result) {
  1325. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1326. }
  1327. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1328. }
  1329. /**
  1330. * 荣衔奖向上追溯
  1331. * @return mixed
  1332. * @throws \yii\base\Exception
  1333. * @throws \yii\db\Exception
  1334. * @throws HttpException
  1335. */
  1336. public function actionTraceUpYc() {
  1337. $periodNum = Yii::$app->request->get('periodNum');
  1338. if (!$periodNum) return static::notice([]);
  1339. $period = Period::instance();
  1340. $yearMonth = $period->getYearMonth($periodNum);
  1341. $filter = $this->filterCondition([
  1342. 'userName' => 'UI.USER_NAME',
  1343. 'periodNum' => 'CBY.PERIOD_NUM',
  1344. ]);
  1345. $condition = $filter['condition'];
  1346. $params = $filter['params'];
  1347. $listObj = new TraceUpYcList();
  1348. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1349. return static::notice($data);
  1350. }
  1351. /**
  1352. * 荣衔奖向上追溯导出
  1353. * @return mixed
  1354. * @throws \yii\db\Exception
  1355. * @throws HttpException
  1356. */
  1357. public function actionTraceUpYcExport() {
  1358. $periodNum = Yii::$app->request->get('periodNum');
  1359. if (!$periodNum) return static::notice([]);
  1360. $period = Period::instance();
  1361. $yearMonth = $period->getYearMonth($periodNum);
  1362. $filter = $this->filterCondition([
  1363. 'userName' => 'UI.USER_NAME',
  1364. 'periodNum' => 'CBY.PERIOD_NUM',
  1365. ]);
  1366. $form = new BonusExportForm();
  1367. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1368. if (!$result) {
  1369. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1370. }
  1371. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1372. }
  1373. /**
  1374. * 服务奖向上追溯
  1375. * @return mixed
  1376. * @throws \yii\base\Exception
  1377. * @throws \yii\db\Exception
  1378. * @throws HttpException
  1379. */
  1380. public function actionTraceUpBd() {
  1381. $periodNum = Yii::$app->request->get('periodNum');
  1382. if (!$periodNum) return static::notice([]);
  1383. $period = Period::instance();
  1384. $yearMonth = $period->getYearMonth($periodNum);
  1385. $filter = $this->filterCondition([
  1386. 'userName' => 'UI.USER_NAME',
  1387. 'periodNum' => 'CBB.PERIOD_NUM',
  1388. ]);
  1389. $condition = $filter['condition'];
  1390. $params = $filter['params'];
  1391. $listObj = new TraceUpBdList();
  1392. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1393. return static::notice($data);
  1394. }
  1395. /**
  1396. * 服务奖向上追溯导出
  1397. * @return mixed
  1398. * @throws \yii\db\Exception
  1399. * @throws HttpException
  1400. */
  1401. public function actionTraceUpBdExport() {
  1402. $periodNum = Yii::$app->request->get('periodNum');
  1403. if (!$periodNum) return static::notice([]);
  1404. $period = Period::instance();
  1405. $yearMonth = $period->getYearMonth($periodNum);
  1406. $filter = $this->filterCondition([
  1407. 'userName' => 'UI.USER_NAME',
  1408. 'periodNum' => 'CBY.PERIOD_NUM',
  1409. ]);
  1410. $form = new BonusExportForm();
  1411. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1412. if (!$result) {
  1413. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1414. }
  1415. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1416. }
  1417. /**
  1418. * 推广奖向上追溯
  1419. * @return mixed
  1420. * @throws \yii\base\Exception
  1421. * @throws \yii\db\Exception
  1422. * @throws HttpException
  1423. */
  1424. public function actionTraceUpTg() {
  1425. $periodNum = Yii::$app->request->get('periodNum');
  1426. if (!$periodNum) return static::notice([]);
  1427. $period = Period::instance();
  1428. $yearMonth = $period->getYearMonth($periodNum);
  1429. $filter = $this->filterCondition([
  1430. 'userName' => 'UI.USER_NAME',
  1431. 'periodNum' => 'CTG.PERIOD_NUM',
  1432. ]);
  1433. $condition = $filter['condition'];
  1434. $params = $filter['params'];
  1435. $listObj = new TraceUpTgList();
  1436. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1437. return static::notice($data);
  1438. }
  1439. /**
  1440. * 推广奖向上追溯导出
  1441. * @return mixed
  1442. * @throws \yii\db\Exception
  1443. * @throws HttpException
  1444. */
  1445. public function actionTraceUpTgExport() {
  1446. $periodNum = Yii::$app->request->get('periodNum');
  1447. if (!$periodNum) return static::notice([]);
  1448. $period = Period::instance();
  1449. $yearMonth = $period->getYearMonth($periodNum);
  1450. $filter = $this->filterCondition([
  1451. 'userName' => 'UI.USER_NAME',
  1452. 'periodNum' => 'CTG.PERIOD_NUM',
  1453. ]);
  1454. $form = new BonusExportForm();
  1455. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1456. if (!$result) {
  1457. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1458. }
  1459. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1460. }
  1461. /**
  1462. * 消费奖向上追溯
  1463. * @return mixed
  1464. * @throws \yii\base\Exception
  1465. * @throws \yii\db\Exception
  1466. * @throws HttpException
  1467. */
  1468. public function actionTraceUpXf() {
  1469. $periodNum = Yii::$app->request->get('periodNum');
  1470. if (!$periodNum) return static::notice([]);
  1471. $period = Period::instance();
  1472. $yearMonth = $period->getYearMonth($periodNum);
  1473. $filter = $this->filterCondition([
  1474. 'userName' => 'UI.USER_NAME',
  1475. 'periodNum' => 'CXF.PERIOD_NUM',
  1476. ]);
  1477. $condition = $filter['condition'];
  1478. $params = $filter['params'];
  1479. $listObj = new TraceUpXfList();
  1480. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1481. return static::notice($data);
  1482. }
  1483. /**
  1484. * 推广奖向上追溯导出
  1485. * @return mixed
  1486. * @throws \yii\db\Exception
  1487. * @throws HttpException
  1488. */
  1489. public function actionTraceUpXfExport() {
  1490. $periodNum = Yii::$app->request->get('periodNum');
  1491. if (!$periodNum) return static::notice([]);
  1492. $period = Period::instance();
  1493. $yearMonth = $period->getYearMonth($periodNum);
  1494. $filter = $this->filterCondition([
  1495. 'userName' => 'UI.USER_NAME',
  1496. 'periodNum' => 'CXF.PERIOD_NUM',
  1497. ]);
  1498. $form = new BonusExportForm();
  1499. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1500. if (!$result) {
  1501. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1502. }
  1503. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1504. }
  1505. /**
  1506. * 业绩奖向上追溯
  1507. * @return mixed
  1508. * @throws \yii\base\Exception
  1509. * @throws \yii\db\Exception
  1510. * @throws HttpException
  1511. */
  1512. public function actionTraceUpYj() {
  1513. $periodNum = Yii::$app->request->get('periodNum');
  1514. if (!$periodNum) return static::notice([]);
  1515. $period = Period::instance();
  1516. $yearMonth = $period->getYearMonth($periodNum);
  1517. $filter = $this->filterCondition([
  1518. 'userName' => 'UI.USER_NAME',
  1519. 'periodNum' => 'CYJ.PERIOD_NUM',
  1520. ]);
  1521. $condition = $filter['condition'];
  1522. $params = $filter['params'];
  1523. $listObj = new TraceUpYjList();
  1524. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1525. return static::notice($data);
  1526. }
  1527. /**
  1528. * 业绩奖向上追溯导出
  1529. * @return mixed
  1530. * @throws \yii\db\Exception
  1531. * @throws HttpException
  1532. */
  1533. public function actionTraceUpYjExport() {
  1534. $periodNum = Yii::$app->request->get('periodNum');
  1535. if (!$periodNum) return static::notice([]);
  1536. $period = Period::instance();
  1537. $yearMonth = $period->getYearMonth($periodNum);
  1538. $filter = $this->filterCondition([
  1539. 'userName' => 'UI.USER_NAME',
  1540. 'periodNum' => 'CYJ.PERIOD_NUM',
  1541. ]);
  1542. $form = new BonusExportForm();
  1543. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1544. if (!$result) {
  1545. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1546. }
  1547. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1548. }
  1549. /**
  1550. * 共享奖向上追溯
  1551. * @return mixed
  1552. * @throws \yii\base\Exception
  1553. * @throws \yii\db\Exception
  1554. * @throws HttpException
  1555. */
  1556. public function actionTraceUpGx() {
  1557. $periodNum = Yii::$app->request->get('periodNum');
  1558. if (!$periodNum) return static::notice([]);
  1559. $period = Period::instance();
  1560. $yearMonth = $period->getYearMonth($periodNum);
  1561. $filter = $this->filterCondition([
  1562. 'userName' => 'UI.USER_NAME',
  1563. 'periodNum' => 'CGX.PERIOD_NUM',
  1564. ]);
  1565. $condition = $filter['condition'];
  1566. $params = $filter['params'];
  1567. $listObj = new TraceUpGxList();
  1568. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1569. return static::notice($data);
  1570. }
  1571. /**
  1572. * 共享奖向上追溯导出
  1573. * @return mixed
  1574. * @throws \yii\db\Exception
  1575. * @throws HttpException
  1576. */
  1577. public function actionTraceUpGxExport() {
  1578. $periodNum = Yii::$app->request->get('periodNum');
  1579. if (!$periodNum) return static::notice([]);
  1580. $period = Period::instance();
  1581. $yearMonth = $period->getYearMonth($periodNum);
  1582. $filter = $this->filterCondition([
  1583. 'userName' => 'UI.USER_NAME',
  1584. 'periodNum' => 'CGX.PERIOD_NUM',
  1585. ]);
  1586. $form = new BonusExportForm();
  1587. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1588. if (!$result) {
  1589. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1590. }
  1591. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1592. }
  1593. /**
  1594. * 管理奖向上追溯
  1595. * @return mixed
  1596. * @throws \yii\base\Exception
  1597. * @throws \yii\db\Exception
  1598. * @throws HttpException
  1599. */
  1600. public function actionTraceUpGl() {
  1601. $periodNum = Yii::$app->request->get('periodNum');
  1602. if (!$periodNum) return static::notice([]);
  1603. $period = Period::instance();
  1604. $yearMonth = $period->getYearMonth($periodNum);
  1605. $filter = $this->filterCondition([
  1606. 'userName' => 'UI.USER_NAME',
  1607. 'periodNum' => 'CGL.PERIOD_NUM',
  1608. ]);
  1609. $condition = $filter['condition'];
  1610. $params = $filter['params'];
  1611. $listObj = new TraceUpGlList();
  1612. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1613. return static::notice($data);
  1614. }
  1615. /**
  1616. * 管理奖向上追溯导出
  1617. * @return mixed
  1618. * @throws \yii\db\Exception
  1619. * @throws HttpException
  1620. */
  1621. public function actionTraceUpGlExport() {
  1622. $periodNum = Yii::$app->request->get('periodNum');
  1623. if (!$periodNum) return static::notice([]);
  1624. $period = Period::instance();
  1625. $yearMonth = $period->getYearMonth($periodNum);
  1626. $filter = $this->filterCondition([
  1627. 'userName' => 'UI.USER_NAME',
  1628. 'periodNum' => 'CGL.PERIOD_NUM',
  1629. ]);
  1630. $form = new BonusExportForm();
  1631. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1632. if (!$result) {
  1633. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1634. }
  1635. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1636. }
  1637. /**
  1638. * 复销奖向下追溯
  1639. * @return mixed
  1640. * @throws \yii\base\Exception
  1641. * @throws \yii\db\Exception
  1642. * @throws HttpException
  1643. */
  1644. public function actionTraceDownFx() {
  1645. $periodNum = Yii::$app->request->get('periodNum');
  1646. if (!$periodNum) return static::notice([]);
  1647. $period = Period::instance();
  1648. $yearMonth = $period->getYearMonth($periodNum);
  1649. $filter = $this->filterCondition([
  1650. 'userName' => 'UI.USER_NAME',
  1651. 'periodNum' => 'CBF.PERIOD_NUM',
  1652. ]);
  1653. $condition = $filter['condition'];
  1654. $params = $filter['params'];
  1655. $listObj = new TraceDownFxList();
  1656. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1657. return static::notice($data);
  1658. }
  1659. /**
  1660. * 复销奖向下追溯导出
  1661. * @return mixed
  1662. * @throws \yii\db\Exception
  1663. * @throws HttpException
  1664. */
  1665. public function actionTraceDownFxExport() {
  1666. $periodNum = Yii::$app->request->get('periodNum');
  1667. if (!$periodNum) return static::notice([]);
  1668. $period = Period::instance();
  1669. $yearMonth = $period->getYearMonth($periodNum);
  1670. $filter = $this->filterCondition([
  1671. 'userName' => 'UI.USER_NAME',
  1672. 'periodNum' => 'CBF.PERIOD_NUM',
  1673. ]);
  1674. $form = new BonusExportForm();
  1675. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '复销奖向下追溯');
  1676. if (!$result) {
  1677. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1678. }
  1679. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1680. }
  1681. /**
  1682. * 复销奖向上追溯
  1683. * @return mixed
  1684. * @throws \yii\base\Exception
  1685. * @throws \yii\db\Exception
  1686. * @throws HttpException
  1687. */
  1688. public function actionTraceUpFx() {
  1689. $periodNum = Yii::$app->request->get('periodNum');
  1690. if (!$periodNum) return static::notice([]);
  1691. $period = Period::instance();
  1692. $yearMonth = $period->getYearMonth($periodNum);
  1693. $filter = $this->filterCondition([
  1694. 'userName' => 'UI.USER_NAME',
  1695. 'periodNum' => 'CBF.PERIOD_NUM',
  1696. ]);
  1697. $condition = $filter['condition'];
  1698. $params = $filter['params'];
  1699. $listObj = new TraceUpFxList();
  1700. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1701. return static::notice($data);
  1702. }
  1703. /**
  1704. * 复销奖向上追溯导出
  1705. * @return mixed
  1706. * @throws \yii\db\Exception
  1707. * @throws HttpException
  1708. */
  1709. public function actionTraceUpFxExport() {
  1710. $periodNum = Yii::$app->request->get('periodNum');
  1711. if (!$periodNum) return static::notice([]);
  1712. $period = Period::instance();
  1713. $yearMonth = $period->getYearMonth($periodNum);
  1714. $filter = $this->filterCondition([
  1715. 'userName' => 'UI.USER_NAME',
  1716. 'periodNum' => 'CBF.PERIOD_NUM',
  1717. ]);
  1718. $form = new BonusExportForm();
  1719. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '复销奖向上追溯');
  1720. if (!$result) {
  1721. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1722. }
  1723. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1724. }
  1725. /**
  1726. * 核算会员区域津贴
  1727. * @return mixed
  1728. * @throws \yii\db\Exception
  1729. * @throws HttpException
  1730. */
  1731. public function actionCalcQy() {
  1732. $periodNum = Yii::$app->request->get('periodNum');
  1733. $userName = Yii::$app->request->get('userName');
  1734. $period = Period::instance();
  1735. $yearMonth = $period->getYearMonth($periodNum);
  1736. if (!$userId = Info::getUserIdByUserName($userName)) {
  1737. return static::notice('Member does not exist', 400); // 会员不存在
  1738. }
  1739. $data = CalcBonus::findUseSlaves()->yearMonth($yearMonth)->where('PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID', [':PERIOD_NUM' => $periodNum, ':USER_ID' => $userId])->asArray()->one();
  1740. if ($data) {
  1741. $data['REAL_NAME'] = Info::getUserRealNameByUserId($userId);
  1742. $data['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$data['LAST_DEC_LV']]['LEVEL_NAME']??'';
  1743. $data['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$data['LAST_EMP_LV']]['LEVEL_NAME']??'';
  1744. $data['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$data['LAST_STATUS']]['label']??'';
  1745. $data['AUDIT_STATUS'] = false;
  1746. 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()) {
  1747. $data['AUDIT_STATUS'] = $resendQy['AUDIT_STATUS'];
  1748. }
  1749. }
  1750. return static::notice($data);
  1751. }
  1752. /**
  1753. * 补发区域津贴列表
  1754. * @return mixed
  1755. * @throws \yii\base\Exception
  1756. * @throws HttpException
  1757. */
  1758. public function actionResendQyList() {
  1759. $filter = $this->filterCondition([
  1760. 'userIds' => 'USER_ID',
  1761. 'filterStatus' => 'RESEND_STATUS',
  1762. 'PERIOD_NUM' => 'PERIOD_NUM',
  1763. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  1764. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  1765. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  1766. 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
  1767. 'LAST_AREA_NAME' => [
  1768. 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1769. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1770. ],
  1771. 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
  1772. 'BONUS_QY' => 'BONUS_QY',
  1773. 'SHOULD_QY' => 'SHOULD_QY',
  1774. 'QY_1L' => 'QY_1L',
  1775. 'SURPLUS_1L' => 'SURPLUS_1L',
  1776. 'QY_2L' => 'QY_2L',
  1777. 'SURPLUS_2L' => 'SURPLUS_2L',
  1778. 'QY_3L' => 'QY_3L',
  1779. 'SURPLUS_3L' => 'SURPLUS_3L',
  1780. 'QY_4L' => 'QY_4L',
  1781. 'SURPLUS_4L' => 'SURPLUS_4L',
  1782. 'QY_5L' => 'QY_5L',
  1783. 'SURPLUS_5L' => 'SURPLUS_5L',
  1784. 'SURPLUS_LS' => 'SURPLUS_LS',
  1785. 'QY_LS' => 'QY_LS',
  1786. ]);
  1787. $condition = $filter['condition'];
  1788. $params = $filter['params'];
  1789. $listObj = new ResendQyList();
  1790. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1791. return static::notice($data);
  1792. }
  1793. /**
  1794. * 区域津贴补发列表导出
  1795. * @return mixed
  1796. * @throws \yii\db\Exception
  1797. * @throws HttpException
  1798. */
  1799. public function actionResendQyListExport() {
  1800. $filter = $this->filterCondition([
  1801. 'userIds' => 'USER_ID',
  1802. 'filterStatus' => 'RESEND_STATUS',
  1803. 'PERIOD_NUM' => 'PERIOD_NUM',
  1804. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  1805. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  1806. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  1807. 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
  1808. 'LAST_AREA_NAME' => [
  1809. 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1810. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1811. ],
  1812. 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
  1813. 'BONUS_QY' => 'BONUS_QY',
  1814. 'SHOULD_QY' => 'SHOULD_QY',
  1815. 'QY_1L' => 'QY_1L',
  1816. 'SURPLUS_1L' => 'SURPLUS_1L',
  1817. 'QY_2L' => 'QY_2L',
  1818. 'SURPLUS_2L' => 'SURPLUS_2L',
  1819. 'QY_3L' => 'QY_3L',
  1820. 'SURPLUS_3L' => 'SURPLUS_3L',
  1821. 'QY_4L' => 'QY_4L',
  1822. 'SURPLUS_4L' => 'SURPLUS_4L',
  1823. 'QY_5L' => 'QY_5L',
  1824. 'SURPLUS_5L' => 'SURPLUS_5L',
  1825. 'SURPLUS_LS' => 'SURPLUS_LS',
  1826. 'QY_LS' => 'QY_LS',
  1827. ]);
  1828. $form = new BonusExportForm();
  1829. $result = $form->run($filter, '区域津贴补发列表');
  1830. if (!$result) {
  1831. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1832. }
  1833. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1834. }
  1835. /**
  1836. * 补发区域津贴
  1837. * @return mixed
  1838. * @throws \yii\db\Exception
  1839. * @throws HttpException
  1840. */
  1841. public function actionResendQy() {
  1842. if (Yii::$app->request->isPost) {
  1843. $formModel = new ResendQYForm();
  1844. $formModel->scenario = 'apply';
  1845. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->apply()) {
  1846. if($result['logs']){
  1847. /*foreach ($result['logs'] as $k => $value) {
  1848. $userName = Info::getUserNameByUserId($value);
  1849. // Log::adminHandle('申请为会员' . $userName . '发放补发区域津贴', 0, $value, $userName);
  1850. }*/
  1851. return static::notice('申请成功,请在补发区域津贴审核管理中审核');
  1852. }else{
  1853. return static::notice('没有符合补发条件的记录',400);
  1854. }
  1855. } else {
  1856. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1857. }
  1858. }
  1859. return static::notice('Illegal request', 400); // 非法请求
  1860. }
  1861. /**
  1862. * 补发审核表
  1863. * @return mixed
  1864. * @throws \yii\base\Exception
  1865. * @throws HttpException
  1866. */
  1867. public function actionResendQyAuditList() {
  1868. $filter = $this->filterCondition([
  1869. 'userIds' => 'RQYA.USER_ID',
  1870. 'filterStatus' => 'RQYA.AUDIT_STATUS',
  1871. 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
  1872. 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
  1873. 'CREATED_AT' => 'RQYA.CREATED_AT',
  1874. 'AUDITED_AT' => 'RQYA.AUDITED_AT',
  1875. 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
  1876. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  1877. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1878. ]);
  1879. $condition = $filter['condition'];
  1880. $params = $filter['params'];
  1881. $listObj = new ResendQyAuditList();
  1882. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1883. return static::notice($data);
  1884. }
  1885. /**
  1886. * 补发审核表导出
  1887. * @return mixed
  1888. * @throws \yii\db\Exception
  1889. * @throws HttpException
  1890. */
  1891. public function actionResendQyAuditListExport() {
  1892. $filter = $this->filterCondition([
  1893. 'userIds' => 'RQYA.USER_ID',
  1894. 'filterStatus' => 'RQYA.AUDIT_STATUS',
  1895. 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
  1896. 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
  1897. 'CREATED_AT' => 'RQYA.CREATED_AT',
  1898. 'AUDITED_AT' => 'RQYA.AUDITED_AT',
  1899. 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
  1900. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  1901. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1902. ]);
  1903. $form = new BonusExportForm();
  1904. $result = $form->run($filter, '补发区域津贴审核列表');
  1905. if (!$result) {
  1906. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1907. }
  1908. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1909. }
  1910. /**
  1911. * 审核补发区域津贴
  1912. * @return mixed
  1913. * @throws \yii\db\Exception
  1914. * @throws HttpException
  1915. */
  1916. public function actionResendQyAudit() {
  1917. $formModel = new ResendQYForm();
  1918. $formModel->scenario = 'audit';
  1919. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1920. /*foreach ($result['logs'] as $k => $value) {
  1921. $userName = Info::getUserNameByUserId($value);
  1922. // Log::adminHandle('审核为会员' . $userName . '补发区域津贴', 1, $value, $userName);
  1923. }*/
  1924. return static::notice('审核补发区域津贴成功');
  1925. }
  1926. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1927. }
  1928. /**
  1929. * 删除补发区域津贴审核信息
  1930. * @return mixed
  1931. * @throws \yii\db\Exception
  1932. * @throws HttpException
  1933. */
  1934. public function actionResendQyAuditDelete() {
  1935. $resendQYForm = new ResendQYForm();
  1936. $result = static::delete(ResendQYAudit::class, function ($selected) use ($resendQYForm) {
  1937. $resendQYForm->beforeDelete($selected);
  1938. // Log::adminHandle('删除审核会员余额信息');
  1939. }, function ($selected) use ($resendQYForm) {
  1940. $resendQYForm->delete($selected);
  1941. // Log::adminHandle('删除审核会员余额信息');
  1942. }, true);
  1943. return $result;
  1944. }
  1945. /**
  1946. * 余额列表
  1947. * @return mixed
  1948. * @throws \yii\base\Exception
  1949. * @throws HttpException
  1950. */
  1951. public function actionBalanceList() {
  1952. $filter = $this->filterCondition([
  1953. 'USER_NAME' => 'UI.USER_NAME',
  1954. 'REAL_NAME' => 'UI.REAL_NAME',
  1955. 'userIds' => 'UB.USER_ID',
  1956. 'BONUS' => 'BONUS',
  1957. // 'RECONSUME_POINTS' => 'RECONSUME_POINTS',
  1958. 'CASH' => 'CASH',
  1959. 'IS_DEC' => 'UI.IS_DEC',
  1960. 'PERIOD_AT' => 'UI.PERIOD_AT',
  1961. 'MOBILE' => 'UI.MOBILE',
  1962. 'TEL' => 'UI.TEL',
  1963. // 'CF' => 'CF',
  1964. // 'LX' => 'LX',
  1965. // 'HIGHEST_EMP_LV_NAME' => 'UI.HIGHEST_EMP_LV',
  1966. // 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1967. ]);
  1968. $condition = $filter['condition'];
  1969. $params = $filter['params'];
  1970. $listObj = new BalanceList();
  1971. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1972. return static::notice($data);
  1973. }
  1974. /**
  1975. * 会员奖金余额导出
  1976. * @return mixed
  1977. * @throws \yii\db\Exception
  1978. * @throws HttpException
  1979. */
  1980. public function actionBalanceExport() {
  1981. $filter = $this->filterCondition([
  1982. 'USER_NAME' => 'UI.USER_NAME',
  1983. 'REAL_NAME' => 'UI.REAL_NAME',
  1984. 'userIds' => 'UB.USER_ID',
  1985. 'BONUS' => 'BONUS',
  1986. 'IS_DEC' => 'UI.IS_DEC',
  1987. 'PERIOD_AT' => 'UI.PERIOD_AT',
  1988. 'MOBILE' => 'UI.MOBILE',
  1989. 'TEL' => 'UI.TEL',
  1990. // 'CF' => 'CF',
  1991. // 'LX' => 'LX',
  1992. ]);
  1993. $form = new BonusExportForm();
  1994. $result = $form->run($filter, '会员奖金余额');
  1995. if (!$result) {
  1996. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1997. }
  1998. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1999. }
  2000. /**
  2001. * 报单中心店补/补贴追溯
  2002. * @return mixed
  2003. * @throws \yii\base\Exception
  2004. * @throws HttpException
  2005. */
  2006. public function actionTraceBt() {
  2007. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2008. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2009. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2010. $filterStatus = Yii::$app->request->get('filterStatus');
  2011. $filter = $this->filterCondition([
  2012. 'userName' => 'UI.USER_NAME',
  2013. ]);
  2014. $condition = $filter['condition'];
  2015. $params = $filter['params'];
  2016. if ($startPeriodNum) {
  2017. $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
  2018. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2019. }
  2020. if ($endPeriodNum) {
  2021. $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
  2022. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2023. }
  2024. if ($filterStatus) {
  2025. $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
  2026. $params[':BT_TYPE'] = $filterStatus;
  2027. }
  2028. $listObj = new TraceBtList();
  2029. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2030. return static::notice($data);
  2031. }
  2032. /**
  2033. * 报单中心补贴追溯导出
  2034. * @return mixed
  2035. * @throws \yii\db\Exception
  2036. * @throws HttpException
  2037. */
  2038. public function actionTraceBtExport() {
  2039. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2040. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2041. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2042. $filterStatus = Yii::$app->request->get('filterStatus');
  2043. $filter = $this->filterCondition([
  2044. 'userName' => 'UI.USER_NAME',
  2045. ]);
  2046. $condition = $filter['condition'];
  2047. $params = $filter['params'];
  2048. if ($startPeriodNum) {
  2049. $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
  2050. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2051. }
  2052. if ($endPeriodNum) {
  2053. $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
  2054. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2055. }
  2056. if ($filterStatus) {
  2057. $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
  2058. $params[':BT_TYPE'] = $filterStatus;
  2059. }
  2060. $form = new BonusExportForm();
  2061. $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心补贴追溯');
  2062. if (!$result) {
  2063. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2064. }
  2065. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2066. }
  2067. /**
  2068. * 报单中心货补追溯
  2069. * @return mixed
  2070. * @throws \yii\base\Exception
  2071. * @throws HttpException
  2072. */
  2073. public function actionTraceFl() {
  2074. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2075. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2076. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2077. $filter = $this->filterCondition([
  2078. 'userName' => 'UI.USER_NAME',
  2079. ]);
  2080. $condition = $filter['condition'];
  2081. $params = $filter['params'];
  2082. if ($startPeriodNum) {
  2083. $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
  2084. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2085. }
  2086. if ($endPeriodNum) {
  2087. $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
  2088. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2089. }
  2090. $listObj = new TraceFlList();
  2091. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2092. return static::notice($data);
  2093. }
  2094. /**
  2095. * 报单中心货补追溯导出
  2096. * @return mixed
  2097. * @throws \yii\db\Exception
  2098. * @throws HttpException
  2099. */
  2100. public function actionTraceFlExport() {
  2101. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2102. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2103. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2104. $filter = $this->filterCondition([
  2105. 'userName' => 'UI.USER_NAME',
  2106. ]);
  2107. $condition = $filter['condition'];
  2108. $params = $filter['params'];
  2109. if ($startPeriodNum) {
  2110. $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
  2111. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2112. }
  2113. if ($endPeriodNum) {
  2114. $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
  2115. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2116. }
  2117. $form = new BonusExportForm();
  2118. $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心货补追溯');
  2119. if (!$result) {
  2120. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2121. }
  2122. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2123. }
  2124. /**
  2125. * 区域业绩提成追溯
  2126. * @return mixed
  2127. * @throws \yii\base\Exception
  2128. * @throws HttpException
  2129. */
  2130. public function actionTraceFw() {
  2131. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2132. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2133. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2134. $filter = $this->filterCondition([
  2135. 'userName' => 'UI.USER_NAME',
  2136. ]);
  2137. $condition = $filter['condition'];
  2138. $params = $filter['params'];
  2139. if ($startPeriodNum) {
  2140. $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
  2141. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2142. }
  2143. if ($endPeriodNum) {
  2144. $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
  2145. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2146. }
  2147. $listObj = new TraceFwList();
  2148. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2149. return static::notice($data);
  2150. }
  2151. /**
  2152. * 区域业绩提成导出
  2153. * @return mixed
  2154. * @throws \yii\db\Exception
  2155. * @throws HttpException
  2156. */
  2157. public function actionTraceFwExport() {
  2158. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2159. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2160. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2161. $filter = $this->filterCondition([
  2162. 'userName' => 'UI.USER_NAME',
  2163. ]);
  2164. $condition = $filter['condition'];
  2165. $params = $filter['params'];
  2166. if ($startPeriodNum) {
  2167. $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
  2168. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2169. }
  2170. if ($endPeriodNum) {
  2171. $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
  2172. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2173. }
  2174. $form = new BonusExportForm();
  2175. $result = $form->run(['condition'=>$condition, 'params'=>$params], '区域业绩提成追溯');
  2176. if (!$result) {
  2177. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2178. }
  2179. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2180. }
  2181. /**
  2182. * 业绩单
  2183. * @return mixed
  2184. * @throws \yii\base\Exception
  2185. * @throws HttpException
  2186. */
  2187. public function actionPerfOrder(){
  2188. $filter = $this->filterCondition([
  2189. 'PERIOD_NUM' => 'PO.PERIOD_NUM',
  2190. 'SN' => 'PO.SN',
  2191. 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
  2192. 'USER_NAME' => 'U.USER_NAME',
  2193. 'REAL_NAME' => 'U.REAL_NAME',
  2194. 'userIds' => 'PO.USER_ID',
  2195. 'filterType' => 'PO.DEC_TYPE',
  2196. 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
  2197. 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
  2198. 'PV' => 'PO.PV',
  2199. 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
  2200. 'DEC_SN' => 'PO.DEC_SN',
  2201. 'CREATED_AT' => 'PO.CREATED_AT',
  2202. ]);
  2203. $condition = $filter['condition'];
  2204. $params = $filter['params'];
  2205. $listObj = new PerfOrderList();
  2206. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2207. return static::notice($data);
  2208. }
  2209. /**
  2210. * 业绩单导出
  2211. * @return mixed
  2212. * @throws \yii\db\Exception
  2213. * @throws HttpException
  2214. */
  2215. public function actionPerfOrderExport() {
  2216. $filter = $this->filterCondition([
  2217. 'PERIOD_NUM' => 'PO.PERIOD_NUM',
  2218. 'SN' => 'PO.SN',
  2219. 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
  2220. 'userIds' => 'PO.USER_ID',
  2221. 'filterType' => 'PO.DEC_TYPE',
  2222. 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
  2223. 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
  2224. 'PV' => 'PO.PV',
  2225. 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
  2226. 'DEC_SN' => 'PO.DEC_SN',
  2227. 'LAST_SUB_COM_NAME' => 'PO.LAST_SUB_COM_ID',
  2228. 'LAST_SYSTEM_NAME' => 'PO.LAST_SYSTEM_ID',
  2229. 'LAST_AREA' => [
  2230. 'FIELD' => ['PO.LAST_PROVINCE', 'PO.LAST_CITY', 'PO.LAST_COUNTY'],
  2231. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  2232. ],
  2233. 'DEC_USER_NAME' => 'DUI.USER_NAME',
  2234. 'LAST_DEC_DEC_LV_NAME' => 'PO.LAST_DEC_DEC_LV',
  2235. 'LAST_DEC_SUB_COM_NAME' => 'PO.LAST_DEC_SUB_COM_ID',
  2236. 'LAST_DEC_AREA' => [
  2237. 'FIELD' => ['PO.LAST_DEC_PROVINCE', 'PO.LAST_DEC_CITY', 'PO.LAST_DEC_COUNTY'],
  2238. 'BIND' => ['LAST_DEC_PROVINCE', 'LAST_DEC_CITY', 'LAST_DEC_COUNTY'],
  2239. ],
  2240. 'CREATED_AT' => 'PO.CREATED_AT',
  2241. 'CLOSED_AT' => 'PO.CLOSED_AT',
  2242. ]);
  2243. $condition = $filter['condition'];
  2244. $params = $filter['params'];
  2245. $form = new BonusExportForm();
  2246. $result = $form->run(['condition'=>$condition, 'params'=>$params], '业绩单');
  2247. if (!$result) {
  2248. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2249. }
  2250. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2251. }
  2252. /**
  2253. * 月积分
  2254. * @return mixed
  2255. * @throws \yii\base\Exception
  2256. * @throws HttpException
  2257. */
  2258. public function actionScoreMonth(){
  2259. $filter = $this->filterCondition([
  2260. 'USER_NAME' => 'U.USER_NAME',
  2261. 'userIds' => 'SM.USER_ID',
  2262. 'CALC_MONTH' => 'SM.CALC_MONTH',
  2263. 'CREATED_AT' => 'SM.CREATED_AT',
  2264. ]);
  2265. $condition = $filter['condition'];
  2266. $params = $filter['params'];
  2267. $listObj = new ScoreMonthList();
  2268. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2269. return static::notice($data);
  2270. }
  2271. /**
  2272. * 月积分导出
  2273. * @return mixed
  2274. * @throws \yii\db\Exception
  2275. * @throws HttpException
  2276. */
  2277. public function actionScoreMonthExport() {
  2278. $filter = $this->filterCondition([
  2279. 'USER_NAME' => 'U.USER_NAME',
  2280. 'userIds' => 'SM.USER_ID',
  2281. 'CALC_MONTH' => 'SM.CALC_MONTH',
  2282. 'CREATED_AT' => 'SM.CREATED_AT',
  2283. ]);
  2284. $condition = $filter['condition'];
  2285. $params = $filter['params'];
  2286. $form = new BonusExportForm();
  2287. $result = $form->run(['condition'=>$condition, 'params'=>$params], '月积分');
  2288. if (!$result) {
  2289. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2290. }
  2291. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2292. }
  2293. /**
  2294. * 月业绩
  2295. * @return mixed
  2296. * @throws \yii\base\Exception
  2297. * @throws HttpException
  2298. */
  2299. public function actionPerfMonth(){
  2300. $filter = $this->filterCondition([
  2301. 'USER_NAME' => 'U.USER_NAME',
  2302. 'REC_USER_NAME' => 'RU.USER_NAME',
  2303. 'userIds' => 'PM.USER_ID',
  2304. 'CALC_MONTH' => 'PM.CALC_MONTH',
  2305. 'CREATED_AT' => 'PM.CREATED_AT',
  2306. ]);
  2307. $condition = $filter['condition'];
  2308. $params = $filter['params'];
  2309. $listObj = new PerfMonthList();
  2310. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2311. return static::notice($data);
  2312. }
  2313. /**
  2314. * 月业绩导出
  2315. * @return mixed
  2316. * @throws \yii\db\Exception
  2317. * @throws HttpException
  2318. */
  2319. public function actionPerfMonthExport() {
  2320. $filter = $this->filterCondition([
  2321. 'USER_NAME' => 'U.USER_NAME',
  2322. 'REC_USER_NAME' => 'RU.USER_NAME',
  2323. 'userIds' => 'PM.USER_ID',
  2324. 'CALC_MONTH' => 'PM.CALC_MONTH',
  2325. 'CREATED_AT' => 'PM.CREATED_AT',
  2326. ]);
  2327. $condition = $filter['condition'];
  2328. $params = $filter['params'];
  2329. $form = new BonusExportForm();
  2330. $result = $form->run(['condition'=>$condition, 'params'=>$params], '月业绩');
  2331. if (!$result) {
  2332. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2333. }
  2334. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2335. }
  2336. /**
  2337. * 期业绩
  2338. * @return mixed
  2339. * @throws \yii\base\Exception
  2340. * @throws HttpException
  2341. */
  2342. public function actionPerfPeriodList(){
  2343. $filter = $this->filterCondition([
  2344. 'USER_NAME' => 'U.USER_NAME',
  2345. 'userIds' => 'PP.USER_ID',
  2346. 'PERIOD_NUM' => 'PP.PERIOD_NUM',
  2347. 'CREATED_AT' => 'PP.CREATED_AT',
  2348. ]);
  2349. $condition = $filter['condition'];
  2350. $params = $filter['params'];
  2351. $listObj = new PerfPeriodList();
  2352. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2353. return static::notice($data);
  2354. }
  2355. /**
  2356. * 期业绩导出
  2357. * @return mixed
  2358. * @throws \yii\db\Exception
  2359. * @throws HttpException
  2360. */
  2361. public function actionPerfPeriodListExport() {
  2362. $filter = $this->filterCondition([
  2363. 'USER_NAME' => 'U.USER_NAME',
  2364. 'userIds' => 'PP.USER_ID',
  2365. 'PERIOD_NUM' => 'PP.PERIOD_NUM',
  2366. 'CREATED_AT' => 'PP.CREATED_AT',
  2367. ]);
  2368. $condition = $filter['condition'];
  2369. $params = $filter['params'];
  2370. $form = new BonusExportForm();
  2371. $result = $form->run(['condition'=>$condition, 'params'=>$params], '期业绩');
  2372. if (!$result) {
  2373. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2374. }
  2375. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2376. }
  2377. /**
  2378. * 达标业绩
  2379. * @return mixed
  2380. * @throws \yii\base\Exception
  2381. * @throws HttpException
  2382. */
  2383. public function actionPerfStandard(){
  2384. $filter = $this->filterCondition([
  2385. 'USER_NAME' => 'U.USER_NAME',
  2386. 'REC_USER_NAME' => 'RU.USER_NAME',
  2387. 'userIds' => 'PS.USER_ID',
  2388. 'CALC_MONTH' => 'PS.CALC_MONTH',
  2389. 'CREATED_AT' => 'PS.CREATED_AT',
  2390. ]);
  2391. $condition = $filter['condition'];
  2392. $params = $filter['params'];
  2393. $listObj = new PerfStandardList();
  2394. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2395. return static::notice($data);
  2396. }
  2397. /**
  2398. * 达标业绩导出
  2399. * @return mixed
  2400. * @throws \yii\db\Exception
  2401. * @throws HttpException
  2402. */
  2403. public function actionPerfStandardExport() {
  2404. $filter = $this->filterCondition([
  2405. 'USER_NAME' => 'U.USER_NAME',
  2406. 'REC_USER_NAME' => 'RU.USER_NAME',
  2407. 'userIds' => 'PS.USER_ID',
  2408. 'CALC_MONTH' => 'PS.CALC_MONTH',
  2409. 'CREATED_AT' => 'PS.CREATED_AT',
  2410. ]);
  2411. $condition = $filter['condition'];
  2412. $params = $filter['params'];
  2413. $form = new BonusExportForm();
  2414. $result = $form->run(['condition'=>$condition, 'params'=>$params], '达标业绩');
  2415. if (!$result) {
  2416. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2417. }
  2418. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2419. }
  2420. /**
  2421. * 会员实时业绩
  2422. * @return mixed
  2423. * @throws HttpException
  2424. */
  2425. public function actionRealTimePerf() {
  2426. $userName = Yii::$app->request->get('userName');
  2427. if (!$userId = Info::getUserIdByUserName($userName)) {
  2428. return static::notice('Member does not exist', 400); // 会员不存在
  2429. }
  2430. $period = Period::instance();
  2431. $newPerf = Perf::getPeriodNewPerf($userId);
  2432. $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'])]];
  2433. $monthPerf = Perf::getMonthPerf($userId);
  2434. $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'])]];
  2435. $lastMonth = PerfMonth::getMonthPerf($period->getLastMonth()['yearMonth'], $userId);
  2436. $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'])]];
  2437. //是否合格
  2438. // $lastChkStatus = '';
  2439. // $lastMonthPerfChk = Cache::getSystemConfig()['lastMonthPerfChk']['VALUE'];
  2440. // $lastArr = [$lastMonth['PV_1L_TOTAL'], $lastMonth['PV_2L_TOTAL'], $lastMonth['PV_3L_TOTAL'], $lastMonth['PV_4L_TOTAL'], $lastMonth['PV_5L_TOTAL']];
  2441. // if (array_sum($lastArr) >= $lastMonthPerfChk) {
  2442. // $lastChkStatus = '已合格';
  2443. // }
  2444. //判断大区
  2445. // $bigLocation = array_search(max($lastArr), $lastArr) + 1;
  2446. return static::notice(['weekData' => $weekData, 'monthData' => $monthData, 'lastData' => $lastData]);
  2447. }
  2448. /**
  2449. * 荣衔业绩
  2450. * @return mixed
  2451. * @throws HttpException
  2452. */
  2453. public function actionYcPerf() {
  2454. $userName = Yii::$app->request->get('userName');
  2455. if (!$userId = Info::getUserIdByUserName($userName)) {
  2456. return static::notice('Member does not exist', 400); // 会员不存在
  2457. }
  2458. $userPerfData = Perf::getUserPerf($userId);
  2459. $ycPerfList = [];
  2460. //查找推荐的子会员
  2461. $childrenList = UserInfo::findUseDbCalc()->select('USER_ID')->where('REC_UID=:REC_UID', [
  2462. 'REC_UID' => $userId
  2463. ])->asArray()->all();
  2464. $maxPvPss = 0;
  2465. $childSumPerf = 0;
  2466. foreach ($childrenList as $child) {
  2467. $childBaseUser = Info::getBaseUserById($child['USER_ID']);
  2468. if( !$childBaseUser ) continue;
  2469. $childPerfData = Perf::getUserPerf($child['USER_ID']);
  2470. if( !$childPerfData ) continue;
  2471. $childPvPcs = $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'];
  2472. $childPvPssTotal = $childPvPcs + $childPerfData['PV_PSS'];
  2473. $childSumPerf += $childPvPssTotal;
  2474. if( $childPvPssTotal >= $maxPvPss ) {
  2475. $maxPvPss = $childPvPssTotal;
  2476. }
  2477. $ycPerfList[] = [
  2478. 'USER_NAME'=>$childBaseUser['USER_NAME'],
  2479. 'REAL_NAME'=>$childBaseUser['REAL_NAME'],
  2480. 'PV_PCS' => $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'],
  2481. 'PV_PSS_TOTAL' => $childPerfData['PV_PSS_TOTAL'],
  2482. 'MAX_DEPART_PERF' => '-',
  2483. 'OTHER_DEPART_PERF' => '-',
  2484. 'PV_PSS_SUM_TOTAL' => round($childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'] + $childPerfData['PV_PSS_TOTAL'],2),
  2485. ];
  2486. }
  2487. if( $userPerfData ) {
  2488. $baseUser = Info::getBaseUserById($userId);
  2489. $ycPerfData = [
  2490. 'USER_NAME'=>$baseUser['USER_NAME'],
  2491. 'REAL_NAME'=>$baseUser['REAL_NAME'],
  2492. 'PV_PCS' => $userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'],
  2493. 'PV_PSS_TOTAL' => $userPerfData['PV_PSS_TOTAL'],
  2494. 'MAX_DEPART_PERF' => round($maxPvPss, 2),
  2495. 'OTHER_DEPART_PERF' => round($childSumPerf-$maxPvPss, 2),
  2496. 'PV_PSS_SUM_TOTAL' => round($userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'] + $userPerfData['PV_PSS_TOTAL'],2),
  2497. ];
  2498. array_unshift($ycPerfList, $ycPerfData);
  2499. }
  2500. return static::notice(['ycPerfList' => $ycPerfList]);
  2501. }
  2502. /**
  2503. * 用户业绩
  2504. * @return mixed
  2505. * @throws HttpException
  2506. */
  2507. public function actionUserPerf() {
  2508. $filter = $this->filterCondition([
  2509. 'USER_NAME' => 'U.USER_NAME',
  2510. ]);
  2511. $condition = $filter['condition'];
  2512. $params = $filter['params'];
  2513. $listObj = new UserPerfList();
  2514. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2515. return static::notice($data);
  2516. }
  2517. /**
  2518. * 月业绩导出
  2519. * @return mixed
  2520. * @throws \yii\db\Exception
  2521. * @throws HttpException
  2522. */
  2523. public function actionUserPerfExport() {
  2524. $filter = $this->filterCondition([
  2525. 'USER_NAME' => 'U.USER_NAME',
  2526. ]);
  2527. $condition = $filter['condition'];
  2528. $params = $filter['params'];
  2529. $form = new BonusExportForm();
  2530. $result = $form->run(['condition'=>$condition, 'params'=>$params], '用户业绩');
  2531. if (!$result) {
  2532. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2533. }
  2534. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2535. }
  2536. /**
  2537. * 自动提现(奖金)
  2538. *
  2539. */
  2540. public function actionAutoWithdraw() {
  2541. $withdrawLock = Cache::getWithdrawLock();
  2542. if ($withdrawLock!=0){
  2543. return static::notice(Form::formatErrorsForApi('已有进程在生成'), 400);
  2544. }else{
  2545. $formModel = new UserBonusForm();
  2546. $formModel->scenario = 'autoWithdraw';
  2547. if ($formModel->autoWithdrawWebToAsync()) {
  2548. return static::notice('生成提现单 已开始处理,请等待');
  2549. } else {
  2550. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2551. }
  2552. }
  2553. }
  2554. /**
  2555. * 查询安置网下级会员和业绩、修改业绩
  2556. * @return mixed|void
  2557. * @throws HttpException
  2558. * @throws \yii\base\Exception
  2559. */
  2560. public function actionPerfAdjustment()
  2561. {
  2562. // 查询业绩
  2563. if (\Yii::$app->request->isGet) {
  2564. $memberCode = Yii::$app->request->get('memberCode');
  2565. $userId = Info::getUserIdByUserName(trim($memberCode));
  2566. // 查询传入会员业绩
  2567. $perfMarket = UserPerf::getPerfMarket($userId);
  2568. if ($perfMarket) {
  2569. // 查询传入会员的安置网下级
  2570. $memberList = UserNetwork::getFirstFloorChildren($userId);
  2571. $memberList = array_column($memberList, NULL, 'RELATIVE_LOCATION');
  2572. // 左腿1市场
  2573. $leftPerfUserName = (isset($memberList[1]) && $memberList[1]['USER_ID']) ? Info::getUserNameByUserId($memberList[1]['USER_ID']) : '';
  2574. // 右腿2市场
  2575. $rightPerfUserName = (isset($memberList[2]) && $memberList[2]['USER_ID']) ? Info::getUserNameByUserId($memberList[2]['USER_ID']) : '';
  2576. // 会员编号
  2577. $perfMarket['USER_NAME'] = $memberCode;
  2578. $perfMarket['SURPLUS_1L_USER_NAME'] = $leftPerfUserName;
  2579. $perfMarket['SURPLUS_2L_USER_NAME'] = $rightPerfUserName;
  2580. return static::notice(['allData' => $perfMarket]);
  2581. }
  2582. return static::notice('No data', 400);
  2583. } else if (\Yii::$app->request->isPost) {
  2584. $formModel = new PerfAdjustmentForm();
  2585. $formModel->scenario = 'perfAdjustment';
  2586. $post = \Yii::$app->request->post();
  2587. if ($formModel->load($post, '') && $formModel->perfAdjustment()) {
  2588. return static::notice('Successful');
  2589. } else {
  2590. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2591. }
  2592. } else {
  2593. return static::notice('Illegal request', 400); // 非法请求
  2594. }
  2595. }
  2596. }