BonusController.php 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751
  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\exportForms\BonusExportForm;
  10. use backendApi\modules\v1\models\lists\bonus\BalanceList;
  11. use backendApi\modules\v1\models\lists\bonus\FlowBalanceList;
  12. use backendApi\modules\v1\models\lists\bonus\FlowBonusList;
  13. use backendApi\modules\v1\models\lists\bonus\FlowExchangePointsList;
  14. use backendApi\modules\v1\models\lists\bonus\FlowReconsumePointsList;
  15. use backendApi\modules\v1\models\lists\bonus\FlowWalletList;
  16. use backendApi\modules\v1\models\lists\bonus\PerfMonthList;
  17. use backendApi\modules\v1\models\lists\bonus\PerfOrderList;
  18. use backendApi\modules\v1\models\lists\bonus\PerfPeriodList;
  19. use backendApi\modules\v1\models\lists\bonus\PerfStandardList;
  20. use backendApi\modules\v1\models\lists\bonus\PeriodBonusList;
  21. use backendApi\modules\v1\models\lists\bonus\ScoreMonthList;
  22. use backendApi\modules\v1\models\lists\bonus\TraceDownBdList;
  23. use backendApi\modules\v1\models\lists\bonus\TraceDownGlList;
  24. use backendApi\modules\v1\models\lists\bonus\TraceDownGxList;
  25. use backendApi\modules\v1\models\lists\bonus\TraceDownQyList;
  26. use backendApi\modules\v1\models\lists\bonus\TraceDownTgList;
  27. use backendApi\modules\v1\models\lists\bonus\TraceDownXfList;
  28. use backendApi\modules\v1\models\lists\bonus\TraceDownYcList;
  29. use backendApi\modules\v1\models\lists\bonus\TraceDownYjList;
  30. use backendApi\modules\v1\models\lists\bonus\TraceUpBdList;
  31. use backendApi\modules\v1\models\lists\bonus\TraceUpGlList;
  32. use backendApi\modules\v1\models\lists\bonus\TraceUpGxList;
  33. use backendApi\modules\v1\models\lists\bonus\TraceUpQyList;
  34. use backendApi\modules\v1\models\lists\bonus\TraceUpTgList;
  35. use backendApi\modules\v1\models\lists\bonus\TraceUpXfList;
  36. use backendApi\modules\v1\models\lists\bonus\TraceUpYcList;
  37. use backendApi\modules\v1\models\lists\bonus\TraceUpYjList;
  38. use backendApi\modules\v1\models\lists\bonus\UserPerfList;
  39. use common\helpers\Cache;
  40. use common\helpers\Tool;
  41. use common\helpers\user\Info;
  42. use common\helpers\user\Perf;
  43. use common\models\CalcBonus;
  44. use common\models\CFLXAudit;
  45. use common\models\forms\PerfAdjustmentForm;
  46. use common\models\forms\ResendQYForm;
  47. use common\models\forms\SendCFAndLXForm;
  48. use common\models\PerfMonth;
  49. use common\models\PerfOrder;
  50. use common\models\PerfPeriod;
  51. use common\models\ResendQYAudit;
  52. use common\models\User;
  53. use common\models\UserInfo;
  54. use common\models\UserNetwork;
  55. use common\models\UserPerf;
  56. use Yii;
  57. use common\helpers\Form;
  58. use common\models\FlowBonus;
  59. use common\models\forms\PeriodForm;
  60. use common\models\forms\UserBonusForm;
  61. use common\models\Period;
  62. use yii\web\HttpException;
  63. class BonusController extends BaseController {
  64. public $modelClass = FlowBonus::class;
  65. public function behaviors() {
  66. return parent::behaviors();
  67. }
  68. /**
  69. * 期数列表
  70. * @return mixed
  71. * @throws \yii\base\InvalidConfigException
  72. * @throws \yii\httpclient\Exception
  73. * @throws HttpException
  74. */
  75. public function actionPeriod() {
  76. $filter = $this->filterCondition([
  77. 'periodNum' => 'PERIOD_NUM',
  78. 'year' => 'CALC_YEAR',
  79. 'month' => 'CALC_MONTH',
  80. 'startTime' => 'START_TIME',
  81. 'endTime' => 'END_TIME',
  82. 'closedAt' => 'CLOSED_AT',
  83. 'perfStartedAt' => 'PERF_STARTED_AT',
  84. 'perfedAt' => 'PERFED_AT',
  85. 'calStartedAt' => 'CALCULATE_STARTED_AT',
  86. 'calculatedAt' => 'CALCULATED_AT',
  87. 'sendStartedAt' => 'SEND_STARTED_AT',
  88. 'sentAt' => 'SENT_AT',
  89. ]);
  90. $condition = $filter['condition'];
  91. $params = $filter['params'];
  92. $periodObj = Period::instance();
  93. $nowPeriodNum = $periodObj->getNowPeriodNum();
  94. // $condition .= ' AND PERIOD_NUM<=:PERIOD_NUM AND STATUS=1';
  95. $condition .= ' AND IS_SENT=0 AND STATUS=1';
  96. // $params[':PERIOD_NUM'] = $nowPeriodNum;
  97. $data = Period::lists($condition, $params, ['orderBy' => 'PERIOD_NUM ASC']);
  98. foreach ($data['list'] as $key => $value) {
  99. // 结算
  100. $data['list'][$key]['IS_CAN_CALC'] = $periodObj->isCanCalc($value['PERIOD_NUM']);
  101. // 挂网
  102. $data['list'][$key]['IS_CAN_SENT'] = $periodObj->isCanSend($value['PERIOD_NUM']);
  103. // 日志
  104. $data['list'][$key]['IS_SHOW_LOG'] = $value['IS_PROCESSING'] > 0 || $value['CALC_ID'];
  105. }
  106. return static::notice($data);
  107. }
  108. /**
  109. * 结算
  110. * @return mixed
  111. * @throws HttpException
  112. */
  113. public function actionCalcPeriod() {
  114. $periodNum = \Yii::$app->request->get('periodNum');
  115. if (!$periodNum) {
  116. return static::notice('期数不存在', 400);
  117. }
  118. $formModel = new PeriodForm();
  119. $formModel->scenario = 'calc';
  120. if ($formModel->load(Yii::$app->request->get(), '') && $formModel->calcWebToAsync()) {
  121. return static::notice('结算已开始处理,请等待');
  122. } else {
  123. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  124. }
  125. }
  126. /**
  127. * 挂网
  128. * @return mixed
  129. * @throws HttpException
  130. */
  131. public function actionSendPeriod() {
  132. $periodNum = \Yii::$app->request->get('periodNum');
  133. if (!$periodNum) {
  134. return static::notice('期数不存在', 400);
  135. }
  136. $formModel = new PeriodForm();
  137. $formModel->scenario = 'send';
  138. if ($formModel->load(Yii::$app->request->get(), '') && $formModel->sendWebToAsync()) {
  139. return static::notice('挂网已开始处理,请等待');
  140. } else {
  141. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  142. }
  143. }
  144. /**
  145. * 查看业绩
  146. * @return mixed
  147. * @throws HttpException
  148. */
  149. public function actionPerf() {
  150. // 获取当前年月
  151. $period = Period::instance();
  152. $yearMonth = $period->getNowYearMonth();
  153. $yearMonth = Yii::$app->request->get('yearMonth', $yearMonth);
  154. //$filter = $this->filterCondition(Perf::tableName(), ['periodNum'=>'P.PERIOD_NUM', 'userName'=>'UI.USER_NAME']);
  155. $condition = '';
  156. $params = [];
  157. $data = PerfPeriod::lists($condition, $params, [
  158. 'select' => 'P.*, UI.USER_NAME',
  159. 'yearMonth' => $yearMonth,
  160. 'from' => PerfPeriod::tableName() . ' AS P',
  161. 'join' => [
  162. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'P.USER_ID=UI.USER_ID']
  163. ],
  164. 'orderBy' => 'P.PERIOD_NUM DESC',
  165. ]);
  166. $data['request'] = [];
  167. $data['request']['yearMonth'] = $yearMonth;
  168. return static::notice($data);
  169. }
  170. /**
  171. * 奖金流水
  172. * @return mixed
  173. * @throws \yii\base\Exception
  174. * @throws HttpException
  175. */
  176. public function actionFlowBonus() {
  177. $filter = $this->filterCondition([
  178. 'USER_NAME' => 'U.USER_NAME',
  179. 'REAL_NAME' => 'U.REAL_NAME',
  180. 'IS_DEC' => 'U.IS_DEC',
  181. 'userIds' => 'USER_ID',
  182. 'CREATED_AT' => 'FB.CREATED_AT',
  183. 'PERIOD_NUM' => 'PERIOD_NUM',
  184. 'CALC_MONTH' => 'CALC_MONTH',
  185. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  186. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  187. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  188. 'AMOUNT' => 'AMOUNT',
  189. 'TOTAL' => 'TOTAL',
  190. 'ADMIN_NAME' => 'ADMIN_NAME',
  191. 'REMARK' => 'REMARK',
  192. 'TRANSFER_SN' => 'TRANSFER_SN',
  193. ]);
  194. $condition = $filter['condition'];
  195. $params = $filter['params'];
  196. $listObj = new FlowBonusList();
  197. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  198. return static::notice($data);
  199. }
  200. /**
  201. * 奖金流水
  202. * @return mixed
  203. * @throws \yii\db\Exception
  204. * @throws HttpException
  205. */
  206. public function actionFlowBonusExport() {
  207. $filter = $this->filterCondition([
  208. 'USER_NAME' => 'U.USER_NAME',
  209. 'REAL_NAME' => 'U.REAL_NAME',
  210. 'IS_DEC' => 'U.IS_DEC',
  211. 'userIds' => 'USER_ID',
  212. 'CREATED_AT' => 'FB.CREATED_AT',
  213. 'PERIOD_NUM' => 'PERIOD_NUM',
  214. 'CALC_MONTH' => 'CALC_MONTH',
  215. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  216. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  217. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  218. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  219. 'AMOUNT' => 'AMOUNT',
  220. 'TOTAL' => 'TOTAL',
  221. 'ADMIN_NAME' => 'ADMIN_NAME',
  222. 'REMARK' => 'REMARK',
  223. 'TRANSFER_SN' => 'TRANSFER_SN',
  224. ]);
  225. $form = new BonusExportForm();
  226. $result = $form->run($filter, 'Bonus_Flow'); // 奖金流水
  227. if (!$result) {
  228. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  229. }
  230. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  231. }
  232. /**
  233. * 复消积分流水
  234. * @return mixed
  235. * @throws \yii\base\Exception
  236. * @throws HttpException
  237. */
  238. public function actionFlowRp() {
  239. $filter = $this->filterCondition([
  240. 'userIds' => 'USER_ID',
  241. 'CREATED_AT' => 'CREATED_AT',
  242. 'PERIOD_NUM' => 'PERIOD_NUM',
  243. 'CALC_MONTH' => 'CALC_MONTH',
  244. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  245. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  246. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  247. 'AMOUNT' => 'AMOUNT',
  248. 'TOTAL' => 'TOTAL',
  249. 'ADMIN_NAME' => 'ADMIN_NAME',
  250. 'REMARK' => 'REMARK',
  251. ]);
  252. $condition = $filter['condition'];
  253. $params = $filter['params'];
  254. $listObj = new FlowReconsumePointsList();
  255. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  256. return static::notice($data);
  257. }
  258. /**
  259. * 复消积分流水导出
  260. * @return mixed
  261. * @throws \yii\db\Exception
  262. * @throws HttpException
  263. */
  264. public function actionFlowRpExport() {
  265. $filter = $this->filterCondition([
  266. 'userIds' => 'USER_ID',
  267. 'CREATED_AT' => 'CREATED_AT',
  268. 'PERIOD_NUM' => 'PERIOD_NUM',
  269. 'CALC_MONTH' => 'CALC_MONTH',
  270. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  271. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  272. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  273. 'AMOUNT' => 'AMOUNT',
  274. 'TOTAL' => 'TOTAL',
  275. 'ADMIN_NAME' => 'ADMIN_NAME',
  276. 'REMARK' => 'REMARK',
  277. ]);
  278. $form = new BonusExportForm();
  279. $result = $form->run($filter, '复消积分流水');
  280. if (!$result) {
  281. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  282. }
  283. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  284. }
  285. /**
  286. * 会员余额流水
  287. * @return mixed
  288. * @throws \yii\base\Exception
  289. * @throws HttpException
  290. */
  291. public function actionFlowBalance() {
  292. $filter = $this->filterCondition([
  293. 'USER_NAME' => 'USER_NAME',
  294. 'REAL_NAME' => 'REAL_NAME',
  295. 'CALC_MONTH' => 'CALC_MONTH',
  296. 'PERIOD_NUM' => 'PERIOD_NUM',
  297. 'TRANSFER_SN' => 'TRANSFER_SN',
  298. 'CREATED_AT' => 'FW.CREATED_AT',
  299. 'AMOUNT' => 'AMOUNT',
  300. 'TOTAL' => 'TOTAL',
  301. 'REMARK' => 'REMARK',
  302. ]);
  303. $condition = $filter['condition'];
  304. $params = $filter['params'];
  305. $listObj = new FlowBalanceList();
  306. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  307. return static::notice($data);
  308. }
  309. /**
  310. * 会员余额流水导出
  311. * @return mixed
  312. * @throws \yii\db\Exception
  313. * @throws HttpException
  314. */
  315. public function actionFlowBalanceExport() {
  316. $filter = $this->filterCondition([
  317. 'USER_NAME' => 'USER_NAME',
  318. 'REAL_NAME' => 'REAL_NAME',
  319. 'CALC_MONTH' => 'CALC_MONTH',
  320. 'PERIOD_NUM' => 'PERIOD_NUM',
  321. 'TRANSFER_SN' => 'TRANSFER_SN',
  322. 'CREATED_AT' => 'FW.CREATED_AT',
  323. 'AMOUNT' => 'AMOUNT',
  324. 'TOTAL' => 'TOTAL',
  325. 'REMARK' => 'REMARK',
  326. ]);
  327. $form = new BonusExportForm();
  328. $result = $form->run($filter, '会员余额流水');
  329. if (!$result) {
  330. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  331. }
  332. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  333. }
  334. /**
  335. * 兑换积分流水
  336. * @return mixed
  337. * @throws \yii\base\Exception
  338. * @throws HttpException
  339. */
  340. public function actionFlowExchange() {
  341. $filter = $this->filterCondition([
  342. 'userIds' => 'USER_ID',
  343. 'CREATED_AT' => 'CREATED_AT',
  344. 'PERIOD_NUM' => 'PERIOD_NUM',
  345. 'CALC_MONTH' => 'CALC_MONTH',
  346. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  347. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  348. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  349. 'AMOUNT' => 'AMOUNT',
  350. 'TOTAL' => 'TOTAL',
  351. 'ADMIN_NAME' => 'ADMIN_NAME',
  352. 'REMARK' => 'REMARK',
  353. ]);
  354. $condition = $filter['condition'];
  355. $params = $filter['params'];
  356. $listObj = new FlowExchangePointsList();
  357. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  358. return static::notice($data);
  359. }
  360. /**
  361. * 兑换积分流水导出
  362. * @return mixed
  363. * @throws \yii\db\Exception
  364. * @throws HttpException
  365. */
  366. public function actionFlowExchangeExport() {
  367. $filter = $this->filterCondition([
  368. 'userIds' => 'USER_ID',
  369. 'CREATED_AT' => 'CREATED_AT',
  370. 'PERIOD_NUM' => 'PERIOD_NUM',
  371. 'CALC_MONTH' => 'CALC_MONTH',
  372. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  373. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  374. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  375. 'AMOUNT' => 'AMOUNT',
  376. 'TOTAL' => 'TOTAL',
  377. 'ADMIN_NAME' => 'ADMIN_NAME',
  378. 'REMARK' => 'REMARK',
  379. ]);
  380. $form = new BonusExportForm();
  381. $result = $form->run($filter, '兑换积分流水');
  382. if (!$result) {
  383. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  384. }
  385. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  386. }
  387. /**
  388. * 现金钱包流水
  389. * @return mixed
  390. * @throws \yii\base\Exception
  391. * @throws HttpException
  392. */
  393. public function actionFlowWallet() {
  394. $filter = $this->filterCondition([
  395. 'USER_NAME' => 'U.USER_NAME',
  396. 'REAL_NAME' => 'U.REAL_NAME',
  397. 'IS_DEC' => 'U.IS_DEC',
  398. 'userIds' => 'USER_ID',
  399. 'CREATED_AT' => 'CREATED_AT',
  400. 'PERIOD_NUM' => 'PERIOD_NUM',
  401. 'CALC_MONTH' => 'CALC_MONTH',
  402. 'AMOUNT' => 'AMOUNT',
  403. 'TOTAL' => 'TOTAL',
  404. 'ADMIN_NAME' => 'ADMIN_NAME',
  405. 'REMARK' => 'REMARK',
  406. ]);
  407. $condition = $filter['condition'];
  408. $params = $filter['params'];
  409. $listObj = new FlowWalletList();
  410. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  411. return static::notice($data);
  412. }
  413. /**
  414. * 现金钱包流水导出
  415. * @return mixed
  416. * @throws \yii\db\Exception
  417. * @throws HttpException
  418. */
  419. public function actionFlowWalletExport() {
  420. $filter = $this->filterCondition([
  421. 'USER_NAME' => 'U.USER_NAME',
  422. 'REAL_NAME' => 'U.REAL_NAME',
  423. 'IS_DEC' => 'U.IS_DEC',
  424. 'userIds' => 'USER_ID',
  425. 'CREATED_AT' => 'CREATED_AT',
  426. 'PERIOD_NUM' => 'PERIOD_NUM',
  427. 'CALC_MONTH' => 'CALC_MONTH',
  428. 'AMOUNT' => 'AMOUNT',
  429. 'TOTAL' => 'TOTAL',
  430. 'ADMIN_NAME' => 'ADMIN_NAME',
  431. 'REMARK' => 'REMARK',
  432. ]);
  433. $form = new BonusExportForm();
  434. $result = $form->run($filter, '现金钱包流水');
  435. if (!$result) {
  436. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  437. }
  438. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  439. }
  440. /**
  441. * 车房流水
  442. * @return mixed
  443. * @throws \yii\base\Exception
  444. * @throws HttpException
  445. */
  446. public function actionFlowCf() {
  447. $filter = $this->filterCondition([
  448. 'userIds' => 'USER_ID',
  449. 'CREATED_AT' => 'CREATED_AT',
  450. 'PERIOD_NUM' => 'PERIOD_NUM',
  451. 'CALC_MONTH' => 'CALC_MONTH',
  452. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  453. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  454. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  455. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  456. 'AMOUNT' => 'AMOUNT',
  457. 'TOTAL' => 'TOTAL',
  458. 'ADMIN_NAME' => 'ADMIN_NAME',
  459. 'REMARK' => 'REMARK',
  460. ]);
  461. $condition = $filter['condition'];
  462. $params = $filter['params'];
  463. $listObj = new FlowCfList();
  464. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  465. return static::notice($data);
  466. }
  467. /**
  468. * 车房养老奖流水导出
  469. * @return mixed
  470. * @throws \yii\db\Exception
  471. * @throws HttpException
  472. */
  473. public function actionFlowCfExport() {
  474. $filter = $this->filterCondition([
  475. 'userIds' => 'USER_ID',
  476. 'CREATED_AT' => 'CREATED_AT',
  477. 'PERIOD_NUM' => 'PERIOD_NUM',
  478. 'CALC_MONTH' => 'CALC_MONTH',
  479. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  480. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  481. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  482. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  483. 'AMOUNT' => 'AMOUNT',
  484. 'TOTAL' => 'TOTAL',
  485. 'ADMIN_NAME' => 'ADMIN_NAME',
  486. 'REMARK' => 'REMARK',
  487. ]);
  488. $form = new BonusExportForm();
  489. $result = $form->run($filter, '车房养老奖流水');
  490. if (!$result) {
  491. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  492. }
  493. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  494. }
  495. /**
  496. * 领袖分红流水
  497. * @return mixed
  498. * @throws \yii\base\Exception
  499. * @throws HttpException
  500. */
  501. public function actionFlowLx() {
  502. $filter = $this->filterCondition([
  503. 'userIds' => 'USER_ID',
  504. 'CREATED_AT' => 'CREATED_AT',
  505. 'PERIOD_NUM' => 'PERIOD_NUM',
  506. 'CALC_MONTH' => 'CALC_MONTH',
  507. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  508. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  509. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  510. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  511. 'AMOUNT' => 'AMOUNT',
  512. 'TOTAL' => 'TOTAL',
  513. 'ADMIN_NAME' => 'ADMIN_NAME',
  514. 'REMARK' => 'REMARK',
  515. ]);
  516. $condition = $filter['condition'];
  517. $params = $filter['params'];
  518. $listObj = new FlowLxList();
  519. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  520. return static::notice($data);
  521. }
  522. /**
  523. * 导出
  524. * @return mixed
  525. * @throws \yii\db\Exception
  526. * @throws HttpException
  527. */
  528. public function actionFlowLxExport() {
  529. $filter = $this->filterCondition([
  530. 'userIds' => 'USER_ID',
  531. 'CREATED_AT' => 'CREATED_AT',
  532. 'PERIOD_NUM' => 'PERIOD_NUM',
  533. 'CALC_MONTH' => 'CALC_MONTH',
  534. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  535. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  536. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  537. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  538. 'AMOUNT' => 'AMOUNT',
  539. 'TOTAL' => 'TOTAL',
  540. 'ADMIN_NAME' => 'ADMIN_NAME',
  541. 'REMARK' => 'REMARK',
  542. ]);
  543. $form = new BonusExportForm();
  544. $result = $form->run($filter, '领袖分红奖流水');
  545. if (!$result) {
  546. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  547. }
  548. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  549. }
  550. /**
  551. * 车房养老奖和领袖分红年度发放审核列表
  552. * @return mixed
  553. * @throws \yii\base\Exception
  554. * @throws HttpException
  555. */
  556. public function actionCfLxAuditList() {
  557. $filter = $this->filterCondition([
  558. 'userIds' => 'CFLXA.USER_ID',
  559. 'CF' => 'CFLXA.CF',
  560. 'LX' => 'CFLXA.LX',
  561. 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  562. 'CREATED_AT' => 'CFLXA.CREATED_AT',
  563. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  564. 'AUDITED_AT' => 'CFLXA.AUDITED_AT',
  565. 'CREATE_REMARK' => 'CFLXA.CREATE_REMARK',
  566. 'filterStatus' => 'CFLXA.AUDIT_STATUS',
  567. ]);
  568. $condition = $filter['condition'];
  569. $params = $filter['params'];
  570. $listObj = new CfLxAuditList();
  571. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  572. return static::notice($data);
  573. }
  574. /**
  575. * 车房养老奖和领袖分红年度发放审核导出
  576. * @return mixed
  577. * @throws \yii\db\Exception
  578. * @throws HttpException
  579. */
  580. public function actionCfLxAuditExport() {
  581. $filter = $this->filterCondition([
  582. 'userIds' => 'CFLXA.USER_ID',
  583. 'CF' => 'CFLXA.CF',
  584. 'LX' => 'CFLXA.LX',
  585. 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  586. 'CREATED_AT' => 'CFLXA.CREATED_AT',
  587. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  588. 'AUDITED_AT' => 'CFLXA.AUDITED_AT',
  589. 'CREATE_REMARK' => 'CFLXA.CREATE_REMARK',
  590. 'filterStatus' => 'CFLXA.AUDIT_STATUS',
  591. ]);
  592. $form = new BonusExportForm();
  593. $result = $form->run($filter, '年度奖金发放审核');
  594. if (!$result) {
  595. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  596. }
  597. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  598. }
  599. /**
  600. * 申请发放车房养老奖和领袖分红
  601. * @return mixed
  602. * @throws \yii\db\Exception
  603. * @throws HttpException
  604. */
  605. public function actionCfLxApply() {
  606. if (Yii::$app->request->isPost) {
  607. $formModel = new SendCFAndLXForm();
  608. $formModel->scenario = 'apply';
  609. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->apply()) {
  610. if(!empty($result['logs'])){
  611. return static::notice('申请成功,请在年度奖管理中审核');
  612. }else{
  613. return static::notice('申请失败,无符合发放条件会员',400);
  614. }
  615. } else {
  616. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  617. }
  618. }
  619. return static::notice('Illegal request', 400); // 非法请求
  620. }
  621. /**
  622. * 审核车房养老奖和领袖分红
  623. * @return mixed
  624. * @throws \yii\db\Exception
  625. * @throws HttpException
  626. */
  627. public function actionCfLxAudit() {
  628. $formModel = new SendCFAndLXForm();
  629. $formModel->scenario = 'audit';
  630. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  631. return static::notice('审核年度奖申请完成');
  632. }
  633. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  634. }
  635. /**
  636. * 删除车房领袖审核信息
  637. * @return mixed
  638. * @throws \yii\db\Exception
  639. * @throws HttpException
  640. */
  641. public function actionCfLxAuditDelete() {
  642. $sendCFAndLXForm = new SendCFAndLXForm();
  643. $result = static::delete(CFLXAudit::class, function ($selected) use ($sendCFAndLXForm) {
  644. $sendCFAndLXForm->beforeDelete($selected);
  645. // Log::adminHandle('删除审核会员余额信息');
  646. }, function ($selected) use ($sendCFAndLXForm) {
  647. $sendCFAndLXForm->delete($selected);
  648. // Log::adminHandle('删除审核会员余额信息');
  649. }, true);
  650. return $result;
  651. }
  652. /**
  653. * 查看所传期数的各项奖金
  654. * @return mixed
  655. * @throws \yii\db\Exception
  656. * @throws HttpException
  657. */
  658. public function actionPeriodDetail() {
  659. $periodNum = \Yii::$app->request->get('periodNum');
  660. $period = Period::instance();
  661. $periodInfo = $period->setPeriodNum($periodNum);
  662. $yearMonth = $period->getYearMonth($periodNum);
  663. // $filter = $this->filterCondition('UT', [
  664. // 'userName' => 'UI.USER_NAME',
  665. // ]);
  666. $condition = '';
  667. $params = [];
  668. $condition .= ' AND C.PERIOD_NUM=:PERIOD_NUM';
  669. $params[':PERIOD_NUM'] = $periodNum;
  670. if (!$period->isClosed($periodNum)) {
  671. return static::notice('Cannot view this period'); // 该期不能查看
  672. }
  673. $data = CalcBonus::lists($condition, $params, [
  674. 'yearMonth' => $yearMonth,
  675. 'select' => 'C.*,UI.USER_NAME',
  676. 'from' => CalcBonus::tableName() . ' AS C',
  677. 'join' => [
  678. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'C.USER_ID=UI.USER_ID'],
  679. ],
  680. 'orderBy' => 'C.CREATED_AT DESC',
  681. ]);
  682. $data['periodInfo'] = $periodInfo;
  683. return static::notice($data);
  684. }
  685. /**
  686. * 获取最新一期结算的奖金
  687. * @return mixed
  688. * @throws \yii\base\Exception
  689. * @throws \yii\db\Exception
  690. * @throws HttpException
  691. */
  692. public function actionNewPeriodBonus() {
  693. $periodNum = Period::calculatedMaxPeriodNum();
  694. $data = $this->_periodBonus($periodNum);
  695. return static::notice($data);
  696. }
  697. /**
  698. * 最新一期奖金导出
  699. * @return mixed
  700. * @throws \yii\db\Exception
  701. * @throws HttpException
  702. */
  703. public function actionNewPeriodBonusExport() {
  704. $filter = $this->filterCondition([
  705. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  706. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  707. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  708. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  709. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  710. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  711. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  712. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  713. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  714. 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  715. 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  716. 'BONUS_BD' => 'CB.BONUS_BD',
  717. 'BONUS_TG' => 'CB.BONUS_TG',
  718. 'BONUS_YJ' => 'CB.BONUS_YJ',
  719. 'BONUS_GX' => 'CB.BONUS_GX',
  720. // 'BONUS_GL' => 'CB.BONUS_BS',
  721. 'BONUS_GL' => 'CB.BONUS_GL',
  722. 'BONUS_QY' => 'CB.BONUS_QY',
  723. 'BONUS_YC' => 'CB.BONUS_YC',
  724. 'PV_1L' => 'CB.PV_1L',
  725. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  726. 'PV_2L' => 'CB.PV_2L',
  727. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  728. 'PV_3L' => 'CB.PV_3L',
  729. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  730. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  731. 'CALC_MONTH' => 'CB.CALC_MONTH',
  732. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  733. ]);
  734. $periodNum = Period::calculatedMaxPeriodNum();
  735. $period = Period::instance();
  736. $yearMonth = $period->getYearMonth($periodNum);
  737. $filter['condition'] .= ' AND PERIOD_NUM=:PERIOD_NUM';
  738. $filter['params'][':PERIOD_NUM'] = $periodNum;
  739. $form = new BonusExportForm();
  740. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth]]), '最新奖金');
  741. if (!$result) {
  742. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  743. }
  744. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  745. }
  746. /**
  747. * 获取往期已结算的奖金
  748. * @return mixed
  749. * @throws \yii\db\Exception
  750. * @throws HttpException
  751. */
  752. public function actionOtherPeriodBonus() {
  753. $periodNumRequest = \Yii::$app->request->get('periodNum');
  754. if(!$periodNumRequest){
  755. $periodNum = Period::calculatedMaxPeriodNum();
  756. }else{
  757. $periodNum = explode(",", $periodNumRequest)[1];
  758. }
  759. $data = $this->_periodBonus($periodNum,false);
  760. if( isset($data['filterTypes']) && is_array($data['filterTypes']) ) {
  761. $data['filterTypes'] = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> \Yii::t('ctx', 'payCycle')]], $data['filterTypes']);
  762. }
  763. return static::notice($data);
  764. }
  765. /**
  766. * 往期奖金导出
  767. * @return mixed
  768. * @throws \yii\db\Exception
  769. * @throws HttpException
  770. */
  771. public function actionOtherPeriodBonusExport() {
  772. $filter = $this->filterCondition([
  773. 'periodNum' => 'CB.PERIOD_NUM',
  774. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  775. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  776. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  777. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  778. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  779. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  780. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  781. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  782. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  783. 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  784. 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  785. 'BONUS_BD' => 'CB.BONUS_BD',
  786. 'BONUS_TG' => 'CB.BONUS_TG',
  787. 'BONUS_YJ' => 'CB.BONUS_YJ',
  788. 'BONUS_GX' => 'CB.BONUS_GX',
  789. 'BONUS_GL' => 'CB.BONUS_GL',
  790. 'BONUS_QY' => 'CB.BONUS_QY',
  791. 'BONUS_YC' => 'CB.BONUS_YC',
  792. 'PV_1L' => 'CB.PV_1L',
  793. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  794. 'PV_2L' => 'CB.PV_2L',
  795. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  796. 'PV_3L' => 'CB.PV_3L',
  797. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  798. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  799. 'CALC_MONTH' => 'CB.CALC_MONTH',
  800. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  801. ]);
  802. $periodNumRequest = \Yii::$app->request->get('periodNum');
  803. if(!$periodNumRequest){
  804. $periodNum = Period::calculatedMaxPeriodNum();
  805. }else{
  806. $periodNum = explode(",", $periodNumRequest)[1];
  807. }
  808. $period = Period::instance();
  809. $yearMonth = $period->getYearMonth($periodNum);
  810. $form = new BonusExportForm();
  811. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth]]), 'Member Bonus'); // 往期奖金
  812. if (!$result) {
  813. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  814. }
  815. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  816. }
  817. /**
  818. * 获取筛选类型
  819. * @return mixed
  820. * @throws HttpException
  821. */
  822. public function actionOtherPeriodBonusFilterTypes(){
  823. $listObj = new PeriodBonusList();
  824. $filterTypes = $listObj->getFilterTypes();
  825. $filterTypes = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> \Yii::t('ctx', 'payCycle')]], $filterTypes);
  826. return static::notice($filterTypes);
  827. }
  828. /**
  829. * 期数对应的奖金
  830. * @param $periodNum
  831. * @param $periodFilter
  832. * @return array
  833. * @throws \yii\base\Exception
  834. * @throws \yii\db\Exception
  835. */
  836. private function _periodBonus($periodNum,$periodFilter = true) {
  837. $filter = $this->filterCondition([
  838. 'periodNum' => 'CB.PERIOD_NUM',
  839. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  840. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  841. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  842. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  843. 'LAST_ELITE_LV_NAME' => 'CB.LAST_ELITE_LV',
  844. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  845. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  846. 'CALC_MONTH' => 'CB.CALC_MONTH',
  847. ]);
  848. $period = Period::instance();
  849. $yearMonth = $period->getYearMonth($periodNum);
  850. $condition = $filter['condition'];
  851. $params = $filter['params'];
  852. if($periodFilter){
  853. $condition .= ' AND CB.PERIOD_NUM=:PERIOD_NUM';
  854. $params[':PERIOD_NUM'] = $periodNum;
  855. }
  856. $listObj = new PeriodBonusList();
  857. return $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth]]);
  858. }
  859. /**
  860. * 团队奖奖金向下追溯
  861. * @return mixed
  862. * @throws \yii\base\Exception
  863. * @throws \yii\db\Exception
  864. * @throws HttpException
  865. */
  866. public function actionTraceDownQy() {
  867. $periodNum = Yii::$app->request->get('periodNum');
  868. if (!$periodNum) return static::notice(\Yii::t('ctx', 'requirePeriods'), 400);
  869. $userName = Yii::$app->request->get('userName');
  870. if (!$userName) return static::notice(\Yii::t('ctx', 'requireMemberNumber'), 400);
  871. $period = Period::instance();
  872. if (!$period->isCalculated($periodNum)) {
  873. return static::notice([]);
  874. }
  875. $yearMonth = $period->getYearMonth($periodNum);
  876. $filter = $this->filterCondition([
  877. 'decType' => 'PO.DEC_TYPE',
  878. 'periodNum' => 'PO.PERIOD_NUM',
  879. ]);
  880. $qyFilter = $this->_qyFilterCondition($filter['request']);
  881. $filter = array_merge($filter, $qyFilter);
  882. $condition = $filter['condition'];
  883. $params = $filter['params'];
  884. $listObj = new TraceDownQyList();
  885. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  886. return static::notice($data);
  887. }
  888. /**
  889. * 获取
  890. * @param $request
  891. * @return array|string[]
  892. */
  893. private function _qyFilterCondition($request) {
  894. //根据USER_NAME获取USER_ID
  895. $user = User::find()->select('ID')->where('USER_NAME=:USER_NAME', ['USER_NAME'=>$request['userName']])->asArray()->one();
  896. if( !$user ) return [];
  897. //找到这个会员的LOCATION_TAG
  898. $userNetwork = UserNetwork::find()->select(['LOCATION_TAG'])->where('USER_ID=:USER_ID', ['USER_ID'=>$user['ID']])->asArray()->one();
  899. $searchLocationTag = $userNetwork['LOCATION_TAG'];
  900. if( isset($request['location']) && $request['location'] ) {
  901. $searchLocationTag .= $request['location'];
  902. }
  903. return [
  904. 'LOCATION_TAG' => 'LIKE ' . $searchLocationTag . '%'
  905. ];
  906. }
  907. /**
  908. * 团队奖向下追溯导出
  909. * @return mixed
  910. * @throws \yii\db\Exception
  911. * @throws HttpException
  912. */
  913. public function actionTraceDownQyExport() {
  914. $periodNum = Yii::$app->request->get('periodNum');
  915. if (!$periodNum) return static::notice('请填写期数', 400);
  916. $userName = Yii::$app->request->get('userName');
  917. if (!$userName) return static::notice('请填写会员编号', 400);
  918. $period = Period::instance();
  919. if (!$period->isCalculated($periodNum)) {
  920. return static::notice([]);
  921. }
  922. $yearMonth = $period->getYearMonth($periodNum);
  923. $filter = $this->filterCondition([
  924. 'decType' => 'PO.DEC_TYPE',
  925. 'periodNum' => 'PO.PERIOD_NUM',
  926. ]);
  927. $qyFilter = $this->_qyFilterCondition($filter['request']);
  928. $filter = array_merge($filter, $qyFilter);
  929. $form = new BonusExportForm();
  930. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '团队奖向下追溯');
  931. if (!$result) {
  932. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  933. }
  934. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  935. }
  936. /**
  937. * 团队奖向上追溯
  938. * @return mixed
  939. * @throws \yii\base\Exception
  940. * @throws HttpException
  941. */
  942. public function actionTraceUpQy() {
  943. $periodNum = Yii::$app->request->get('periodNum');
  944. if (!$periodNum) return static::notice('请填写期数', 400);
  945. if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
  946. if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('Member does not exist', 400); // 会员不存在
  947. //会员是否有业绩单
  948. if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
  949. return static::notice('该会员本期没有业绩单', 400);
  950. }
  951. $listObj = new TraceUpQyList();
  952. $data = $listObj->getList(['condition'=>'', 'params'=>[], 'others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]);
  953. return static::notice($data);
  954. }
  955. /**
  956. * 团队奖向上追溯导出
  957. * @return mixed
  958. * @throws \yii\db\Exception
  959. * @throws HttpException
  960. */
  961. public function actionTraceUpQyExport() {
  962. $periodNum = Yii::$app->request->get('periodNum');
  963. if (!$periodNum) return static::notice('请填写期数', 400);
  964. if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
  965. if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('Member does not exist', 400); // 会员不存在
  966. //会员是否有业绩单
  967. if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
  968. return static::notice('该会员本期没有业绩单', 400);
  969. }
  970. $form = new BonusExportForm();
  971. $result = $form->run(array_merge(['condition'=>'', 'params'=>[]], ['others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]), '团队奖向上追溯');
  972. if (!$result) {
  973. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  974. }
  975. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  976. }
  977. /**
  978. * 荣衔奖向下追溯
  979. * @return mixed
  980. * @throws \yii\base\Exception
  981. * @throws \yii\db\Exception
  982. * @throws HttpException
  983. */
  984. public function actionTraceDownYc() {
  985. $periodNum = Yii::$app->request->get('periodNum');
  986. if (!$periodNum) return static::notice([]);
  987. $period = Period::instance();
  988. $yearMonth = $period->getYearMonth($periodNum);
  989. $filter = $this->filterCondition([
  990. 'userName' => 'UI.USER_NAME',
  991. 'periodNum' => 'CBY.PERIOD_NUM',
  992. ]);
  993. $condition = $filter['condition'];
  994. $params = $filter['params'];
  995. $listObj = new TraceDownYcList();
  996. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, '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 actionTraceDownYcExport() {
  1006. $periodNum = Yii::$app->request->get('periodNum');
  1007. if (!$periodNum) return static::notice([]);
  1008. $period = Period::instance();
  1009. $yearMonth = $period->getYearMonth($periodNum);
  1010. $filter = $this->filterCondition([
  1011. 'userName' => 'UI.USER_NAME',
  1012. 'periodNum' => 'CBY.PERIOD_NUM',
  1013. ]);
  1014. $form = new BonusExportForm();
  1015. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, '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 actionTraceDownBd() {
  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' => 'CBB.PERIOD_NUM',
  1036. ]);
  1037. $condition = $filter['condition'];
  1038. $params = $filter['params'];
  1039. $listObj = new TraceDownBdList();
  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 actionTraceDownBdExport() {
  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' => 'CBB.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 actionTraceDownTg() {
  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' => 'CTG.PERIOD_NUM',
  1080. ]);
  1081. $condition = $filter['condition'];
  1082. $params = $filter['params'];
  1083. $listObj = new TraceDownTgList();
  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 actionTraceDownTgExport() {
  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' => 'CTG.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 actionTraceDownXf() {
  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' => 'CXF.PERIOD_NUM',
  1124. ]);
  1125. $condition = $filter['condition'];
  1126. $params = $filter['params'];
  1127. $listObj = new TraceDownXfList();
  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 actionTraceDownXfExport() {
  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' => 'CXF.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 actionTraceDownYj() {
  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' => 'CYJ.PERIOD_NUM',
  1168. ]);
  1169. $condition = $filter['condition'];
  1170. $params = $filter['params'];
  1171. $listObj = new TraceDownYjList();
  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 actionTraceDownYjExport() {
  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' => 'CYJ.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 actionTraceDownGx() {
  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' => 'CGX.PERIOD_NUM',
  1212. ]);
  1213. $condition = $filter['condition'];
  1214. $params = $filter['params'];
  1215. $listObj = new TraceDownGxList();
  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 actionTraceDownGxExport() {
  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' => 'CGX.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 actionTraceDownGl() {
  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' => 'CGL.PERIOD_NUM',
  1256. ]);
  1257. $condition = $filter['condition'];
  1258. $params = $filter['params'];
  1259. $listObj = new TraceDownGlList();
  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 actionTraceDownGlExport() {
  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' => 'CGL.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 actionTraceUpYc() {
  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' => 'CBY.PERIOD_NUM',
  1300. ]);
  1301. $condition = $filter['condition'];
  1302. $params = $filter['params'];
  1303. $listObj = new TraceUpYcList();
  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 actionTraceUpYcExport() {
  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' => 'CBY.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 actionTraceUpBd() {
  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' => 'CBB.PERIOD_NUM',
  1344. ]);
  1345. $condition = $filter['condition'];
  1346. $params = $filter['params'];
  1347. $listObj = new TraceUpBdList();
  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 actionTraceUpBdExport() {
  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 actionTraceUpTg() {
  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' => 'CTG.PERIOD_NUM',
  1388. ]);
  1389. $condition = $filter['condition'];
  1390. $params = $filter['params'];
  1391. $listObj = new TraceUpTgList();
  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 actionTraceUpTgExport() {
  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' => 'CTG.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 actionTraceUpXf() {
  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' => 'CXF.PERIOD_NUM',
  1432. ]);
  1433. $condition = $filter['condition'];
  1434. $params = $filter['params'];
  1435. $listObj = new TraceUpXfList();
  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 actionTraceUpXfExport() {
  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' => 'CXF.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 actionTraceUpYj() {
  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' => 'CYJ.PERIOD_NUM',
  1476. ]);
  1477. $condition = $filter['condition'];
  1478. $params = $filter['params'];
  1479. $listObj = new TraceUpYjList();
  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 actionTraceUpYjExport() {
  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' => 'CYJ.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 actionTraceUpGx() {
  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' => 'CGX.PERIOD_NUM',
  1520. ]);
  1521. $condition = $filter['condition'];
  1522. $params = $filter['params'];
  1523. $listObj = new TraceUpGxList();
  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 actionTraceUpGxExport() {
  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' => 'CGX.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 actionTraceUpGl() {
  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' => 'CGL.PERIOD_NUM',
  1564. ]);
  1565. $condition = $filter['condition'];
  1566. $params = $filter['params'];
  1567. $listObj = new TraceUpGlList();
  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 actionTraceUpGlExport() {
  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' => 'CGL.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 actionTraceDownFx() {
  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' => 'CBF.PERIOD_NUM',
  1608. ]);
  1609. $condition = $filter['condition'];
  1610. $params = $filter['params'];
  1611. $listObj = new TraceDownFxList();
  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 actionTraceDownFxExport() {
  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' => 'CBF.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 actionTraceUpFx() {
  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 TraceUpFxList();
  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 actionTraceUpFxExport() {
  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\db\Exception
  1685. * @throws HttpException
  1686. */
  1687. public function actionCalcQy() {
  1688. $periodNum = Yii::$app->request->get('periodNum');
  1689. $userName = Yii::$app->request->get('userName');
  1690. $period = Period::instance();
  1691. $yearMonth = $period->getYearMonth($periodNum);
  1692. if (!$userId = Info::getUserIdByUserName($userName)) {
  1693. return static::notice('Member does not exist', 400); // 会员不存在
  1694. }
  1695. $data = CalcBonus::findUseSlaves()->yearMonth($yearMonth)->where('PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID', [':PERIOD_NUM' => $periodNum, ':USER_ID' => $userId])->asArray()->one();
  1696. if ($data) {
  1697. $data['REAL_NAME'] = Info::getUserRealNameByUserId($userId);
  1698. $data['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$data['LAST_DEC_LV']]['LEVEL_NAME']??'';
  1699. $data['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$data['LAST_EMP_LV']]['LEVEL_NAME']??'';
  1700. $data['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$data['LAST_STATUS']]['label']??'';
  1701. $data['AUDIT_STATUS'] = false;
  1702. 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()) {
  1703. $data['AUDIT_STATUS'] = $resendQy['AUDIT_STATUS'];
  1704. }
  1705. }
  1706. return static::notice($data);
  1707. }
  1708. /**
  1709. * 补发区域津贴列表
  1710. * @return mixed
  1711. * @throws \yii\base\Exception
  1712. * @throws HttpException
  1713. */
  1714. public function actionResendQyList() {
  1715. $filter = $this->filterCondition([
  1716. 'userIds' => 'USER_ID',
  1717. 'filterStatus' => 'RESEND_STATUS',
  1718. 'PERIOD_NUM' => 'PERIOD_NUM',
  1719. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  1720. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  1721. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  1722. 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
  1723. 'LAST_AREA_NAME' => [
  1724. 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1725. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1726. ],
  1727. 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
  1728. 'BONUS_QY' => 'BONUS_QY',
  1729. 'SHOULD_QY' => 'SHOULD_QY',
  1730. 'QY_1L' => 'QY_1L',
  1731. 'SURPLUS_1L' => 'SURPLUS_1L',
  1732. 'QY_2L' => 'QY_2L',
  1733. 'SURPLUS_2L' => 'SURPLUS_2L',
  1734. 'QY_3L' => 'QY_3L',
  1735. 'SURPLUS_3L' => 'SURPLUS_3L',
  1736. 'QY_4L' => 'QY_4L',
  1737. 'SURPLUS_4L' => 'SURPLUS_4L',
  1738. 'QY_5L' => 'QY_5L',
  1739. 'SURPLUS_5L' => 'SURPLUS_5L',
  1740. 'SURPLUS_LS' => 'SURPLUS_LS',
  1741. 'QY_LS' => 'QY_LS',
  1742. ]);
  1743. $condition = $filter['condition'];
  1744. $params = $filter['params'];
  1745. $listObj = new ResendQyList();
  1746. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1747. return static::notice($data);
  1748. }
  1749. /**
  1750. * 区域津贴补发列表导出
  1751. * @return mixed
  1752. * @throws \yii\db\Exception
  1753. * @throws HttpException
  1754. */
  1755. public function actionResendQyListExport() {
  1756. $filter = $this->filterCondition([
  1757. 'userIds' => 'USER_ID',
  1758. 'filterStatus' => 'RESEND_STATUS',
  1759. 'PERIOD_NUM' => 'PERIOD_NUM',
  1760. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  1761. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  1762. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  1763. 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
  1764. 'LAST_AREA_NAME' => [
  1765. 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1766. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1767. ],
  1768. 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
  1769. 'BONUS_QY' => 'BONUS_QY',
  1770. 'SHOULD_QY' => 'SHOULD_QY',
  1771. 'QY_1L' => 'QY_1L',
  1772. 'SURPLUS_1L' => 'SURPLUS_1L',
  1773. 'QY_2L' => 'QY_2L',
  1774. 'SURPLUS_2L' => 'SURPLUS_2L',
  1775. 'QY_3L' => 'QY_3L',
  1776. 'SURPLUS_3L' => 'SURPLUS_3L',
  1777. 'QY_4L' => 'QY_4L',
  1778. 'SURPLUS_4L' => 'SURPLUS_4L',
  1779. 'QY_5L' => 'QY_5L',
  1780. 'SURPLUS_5L' => 'SURPLUS_5L',
  1781. 'SURPLUS_LS' => 'SURPLUS_LS',
  1782. 'QY_LS' => 'QY_LS',
  1783. ]);
  1784. $form = new BonusExportForm();
  1785. $result = $form->run($filter, '区域津贴补发列表');
  1786. if (!$result) {
  1787. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1788. }
  1789. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1790. }
  1791. /**
  1792. * 补发区域津贴
  1793. * @return mixed
  1794. * @throws \yii\db\Exception
  1795. * @throws HttpException
  1796. */
  1797. public function actionResendQy() {
  1798. if (Yii::$app->request->isPost) {
  1799. $formModel = new ResendQYForm();
  1800. $formModel->scenario = 'apply';
  1801. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->apply()) {
  1802. if($result['logs']){
  1803. /*foreach ($result['logs'] as $k => $value) {
  1804. $userName = Info::getUserNameByUserId($value);
  1805. // Log::adminHandle('申请为会员' . $userName . '发放补发区域津贴', 0, $value, $userName);
  1806. }*/
  1807. return static::notice('申请成功,请在补发区域津贴审核管理中审核');
  1808. }else{
  1809. return static::notice('没有符合补发条件的记录',400);
  1810. }
  1811. } else {
  1812. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1813. }
  1814. }
  1815. return static::notice('Illegal request', 400); // 非法请求
  1816. }
  1817. /**
  1818. * 补发审核表
  1819. * @return mixed
  1820. * @throws \yii\base\Exception
  1821. * @throws HttpException
  1822. */
  1823. public function actionResendQyAuditList() {
  1824. $filter = $this->filterCondition([
  1825. 'userIds' => 'RQYA.USER_ID',
  1826. 'filterStatus' => 'RQYA.AUDIT_STATUS',
  1827. 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
  1828. 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
  1829. 'CREATED_AT' => 'RQYA.CREATED_AT',
  1830. 'AUDITED_AT' => 'RQYA.AUDITED_AT',
  1831. 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
  1832. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  1833. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1834. ]);
  1835. $condition = $filter['condition'];
  1836. $params = $filter['params'];
  1837. $listObj = new ResendQyAuditList();
  1838. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1839. return static::notice($data);
  1840. }
  1841. /**
  1842. * 补发审核表导出
  1843. * @return mixed
  1844. * @throws \yii\db\Exception
  1845. * @throws HttpException
  1846. */
  1847. public function actionResendQyAuditListExport() {
  1848. $filter = $this->filterCondition([
  1849. 'userIds' => 'RQYA.USER_ID',
  1850. 'filterStatus' => 'RQYA.AUDIT_STATUS',
  1851. 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
  1852. 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
  1853. 'CREATED_AT' => 'RQYA.CREATED_AT',
  1854. 'AUDITED_AT' => 'RQYA.AUDITED_AT',
  1855. 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
  1856. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  1857. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1858. ]);
  1859. $form = new BonusExportForm();
  1860. $result = $form->run($filter, '补发区域津贴审核列表');
  1861. if (!$result) {
  1862. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1863. }
  1864. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1865. }
  1866. /**
  1867. * 审核补发区域津贴
  1868. * @return mixed
  1869. * @throws \yii\db\Exception
  1870. * @throws HttpException
  1871. */
  1872. public function actionResendQyAudit() {
  1873. $formModel = new ResendQYForm();
  1874. $formModel->scenario = 'audit';
  1875. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1876. /*foreach ($result['logs'] as $k => $value) {
  1877. $userName = Info::getUserNameByUserId($value);
  1878. // Log::adminHandle('审核为会员' . $userName . '补发区域津贴', 1, $value, $userName);
  1879. }*/
  1880. return static::notice('审核补发区域津贴成功');
  1881. }
  1882. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1883. }
  1884. /**
  1885. * 删除补发区域津贴审核信息
  1886. * @return mixed
  1887. * @throws \yii\db\Exception
  1888. * @throws HttpException
  1889. */
  1890. public function actionResendQyAuditDelete() {
  1891. $resendQYForm = new ResendQYForm();
  1892. $result = static::delete(ResendQYAudit::class, function ($selected) use ($resendQYForm) {
  1893. $resendQYForm->beforeDelete($selected);
  1894. // Log::adminHandle('删除审核会员余额信息');
  1895. }, function ($selected) use ($resendQYForm) {
  1896. $resendQYForm->delete($selected);
  1897. // Log::adminHandle('删除审核会员余额信息');
  1898. }, true);
  1899. return $result;
  1900. }
  1901. /**
  1902. * 余额列表
  1903. * @return mixed
  1904. * @throws \yii\base\Exception
  1905. * @throws HttpException
  1906. */
  1907. public function actionBalanceList() {
  1908. $filter = $this->filterCondition([
  1909. 'USER_NAME' => 'UI.USER_NAME',
  1910. 'REAL_NAME' => 'UI.REAL_NAME',
  1911. 'userIds' => 'UB.USER_ID',
  1912. 'BONUS' => 'BONUS',
  1913. // 'RECONSUME_POINTS' => 'RECONSUME_POINTS',
  1914. 'CASH' => 'CASH',
  1915. 'IS_DEC' => 'UI.IS_DEC',
  1916. 'PERIOD_AT' => 'UI.PERIOD_AT',
  1917. 'MOBILE' => 'UI.MOBILE',
  1918. 'TEL' => 'UI.TEL',
  1919. // 'CF' => 'CF',
  1920. // 'LX' => 'LX',
  1921. // 'HIGHEST_EMP_LV_NAME' => 'UI.HIGHEST_EMP_LV',
  1922. // 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1923. ]);
  1924. $condition = $filter['condition'];
  1925. $params = $filter['params'];
  1926. $listObj = new BalanceList();
  1927. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1928. return static::notice($data);
  1929. }
  1930. /**
  1931. * 会员奖金余额导出
  1932. * @return mixed
  1933. * @throws \yii\db\Exception
  1934. * @throws HttpException
  1935. */
  1936. public function actionBalanceExport() {
  1937. $filter = $this->filterCondition([
  1938. 'USER_NAME' => 'UI.USER_NAME',
  1939. 'REAL_NAME' => 'UI.REAL_NAME',
  1940. 'userIds' => 'UB.USER_ID',
  1941. 'BONUS' => 'BONUS',
  1942. 'IS_DEC' => 'UI.IS_DEC',
  1943. 'PERIOD_AT' => 'UI.PERIOD_AT',
  1944. 'MOBILE' => 'UI.MOBILE',
  1945. 'TEL' => 'UI.TEL',
  1946. // 'CF' => 'CF',
  1947. // 'LX' => 'LX',
  1948. ]);
  1949. $form = new BonusExportForm();
  1950. $result = $form->run($filter, '会员奖金余额');
  1951. if (!$result) {
  1952. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1953. }
  1954. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1955. }
  1956. /**
  1957. * 报单中心店补/补贴追溯
  1958. * @return mixed
  1959. * @throws \yii\base\Exception
  1960. * @throws HttpException
  1961. */
  1962. public function actionTraceBt() {
  1963. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  1964. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  1965. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  1966. $filterStatus = Yii::$app->request->get('filterStatus');
  1967. $filter = $this->filterCondition([
  1968. 'userName' => 'UI.USER_NAME',
  1969. ]);
  1970. $condition = $filter['condition'];
  1971. $params = $filter['params'];
  1972. if ($startPeriodNum) {
  1973. $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
  1974. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  1975. }
  1976. if ($endPeriodNum) {
  1977. $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
  1978. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  1979. }
  1980. if ($filterStatus) {
  1981. $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
  1982. $params[':BT_TYPE'] = $filterStatus;
  1983. }
  1984. $listObj = new TraceBtList();
  1985. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1986. return static::notice($data);
  1987. }
  1988. /**
  1989. * 报单中心补贴追溯导出
  1990. * @return mixed
  1991. * @throws \yii\db\Exception
  1992. * @throws HttpException
  1993. */
  1994. public function actionTraceBtExport() {
  1995. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  1996. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  1997. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  1998. $filterStatus = Yii::$app->request->get('filterStatus');
  1999. $filter = $this->filterCondition([
  2000. 'userName' => 'UI.USER_NAME',
  2001. ]);
  2002. $condition = $filter['condition'];
  2003. $params = $filter['params'];
  2004. if ($startPeriodNum) {
  2005. $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
  2006. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2007. }
  2008. if ($endPeriodNum) {
  2009. $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
  2010. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2011. }
  2012. if ($filterStatus) {
  2013. $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
  2014. $params[':BT_TYPE'] = $filterStatus;
  2015. }
  2016. $form = new BonusExportForm();
  2017. $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心补贴追溯');
  2018. if (!$result) {
  2019. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2020. }
  2021. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2022. }
  2023. /**
  2024. * 报单中心货补追溯
  2025. * @return mixed
  2026. * @throws \yii\base\Exception
  2027. * @throws HttpException
  2028. */
  2029. public function actionTraceFl() {
  2030. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2031. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2032. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2033. $filter = $this->filterCondition([
  2034. 'userName' => 'UI.USER_NAME',
  2035. ]);
  2036. $condition = $filter['condition'];
  2037. $params = $filter['params'];
  2038. if ($startPeriodNum) {
  2039. $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
  2040. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2041. }
  2042. if ($endPeriodNum) {
  2043. $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
  2044. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2045. }
  2046. $listObj = new TraceFlList();
  2047. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2048. return static::notice($data);
  2049. }
  2050. /**
  2051. * 报单中心货补追溯导出
  2052. * @return mixed
  2053. * @throws \yii\db\Exception
  2054. * @throws HttpException
  2055. */
  2056. public function actionTraceFlExport() {
  2057. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2058. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2059. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2060. $filter = $this->filterCondition([
  2061. 'userName' => 'UI.USER_NAME',
  2062. ]);
  2063. $condition = $filter['condition'];
  2064. $params = $filter['params'];
  2065. if ($startPeriodNum) {
  2066. $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
  2067. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2068. }
  2069. if ($endPeriodNum) {
  2070. $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
  2071. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2072. }
  2073. $form = new BonusExportForm();
  2074. $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心货补追溯');
  2075. if (!$result) {
  2076. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2077. }
  2078. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2079. }
  2080. /**
  2081. * 区域业绩提成追溯
  2082. * @return mixed
  2083. * @throws \yii\base\Exception
  2084. * @throws HttpException
  2085. */
  2086. public function actionTraceFw() {
  2087. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2088. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2089. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2090. $filter = $this->filterCondition([
  2091. 'userName' => 'UI.USER_NAME',
  2092. ]);
  2093. $condition = $filter['condition'];
  2094. $params = $filter['params'];
  2095. if ($startPeriodNum) {
  2096. $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
  2097. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2098. }
  2099. if ($endPeriodNum) {
  2100. $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
  2101. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2102. }
  2103. $listObj = new TraceFwList();
  2104. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2105. return static::notice($data);
  2106. }
  2107. /**
  2108. * 区域业绩提成导出
  2109. * @return mixed
  2110. * @throws \yii\db\Exception
  2111. * @throws HttpException
  2112. */
  2113. public function actionTraceFwExport() {
  2114. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2115. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2116. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2117. $filter = $this->filterCondition([
  2118. 'userName' => 'UI.USER_NAME',
  2119. ]);
  2120. $condition = $filter['condition'];
  2121. $params = $filter['params'];
  2122. if ($startPeriodNum) {
  2123. $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
  2124. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2125. }
  2126. if ($endPeriodNum) {
  2127. $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
  2128. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2129. }
  2130. $form = new BonusExportForm();
  2131. $result = $form->run(['condition'=>$condition, 'params'=>$params], '区域业绩提成追溯');
  2132. if (!$result) {
  2133. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2134. }
  2135. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2136. }
  2137. /**
  2138. * 业绩单
  2139. * @return mixed
  2140. * @throws \yii\base\Exception
  2141. * @throws HttpException
  2142. */
  2143. public function actionPerfOrder(){
  2144. $filter = $this->filterCondition([
  2145. 'PERIOD_NUM' => 'PO.PERIOD_NUM',
  2146. 'SN' => 'PO.SN',
  2147. 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
  2148. 'USER_NAME' => 'U.USER_NAME',
  2149. 'REAL_NAME' => 'U.REAL_NAME',
  2150. 'userIds' => 'PO.USER_ID',
  2151. 'filterType' => 'PO.DEC_TYPE',
  2152. 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
  2153. 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
  2154. 'PV' => 'PO.PV',
  2155. 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
  2156. 'DEC_SN' => 'PO.DEC_SN',
  2157. 'CREATED_AT' => 'PO.CREATED_AT',
  2158. ]);
  2159. $condition = $filter['condition'];
  2160. $params = $filter['params'];
  2161. $listObj = new PerfOrderList();
  2162. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2163. return static::notice($data);
  2164. }
  2165. /**
  2166. * 业绩单导出
  2167. * @return mixed
  2168. * @throws \yii\db\Exception
  2169. * @throws HttpException
  2170. */
  2171. public function actionPerfOrderExport() {
  2172. $filter = $this->filterCondition([
  2173. 'PERIOD_NUM' => 'PO.PERIOD_NUM',
  2174. 'SN' => 'PO.SN',
  2175. 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
  2176. 'userIds' => 'PO.USER_ID',
  2177. 'filterType' => 'PO.DEC_TYPE',
  2178. 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
  2179. 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
  2180. 'PV' => 'PO.PV',
  2181. 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
  2182. 'DEC_SN' => 'PO.DEC_SN',
  2183. 'LAST_SUB_COM_NAME' => 'PO.LAST_SUB_COM_ID',
  2184. 'LAST_SYSTEM_NAME' => 'PO.LAST_SYSTEM_ID',
  2185. 'LAST_AREA' => [
  2186. 'FIELD' => ['PO.LAST_PROVINCE', 'PO.LAST_CITY', 'PO.LAST_COUNTY'],
  2187. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  2188. ],
  2189. 'DEC_USER_NAME' => 'DUI.USER_NAME',
  2190. 'LAST_DEC_DEC_LV_NAME' => 'PO.LAST_DEC_DEC_LV',
  2191. 'LAST_DEC_SUB_COM_NAME' => 'PO.LAST_DEC_SUB_COM_ID',
  2192. 'LAST_DEC_AREA' => [
  2193. 'FIELD' => ['PO.LAST_DEC_PROVINCE', 'PO.LAST_DEC_CITY', 'PO.LAST_DEC_COUNTY'],
  2194. 'BIND' => ['LAST_DEC_PROVINCE', 'LAST_DEC_CITY', 'LAST_DEC_COUNTY'],
  2195. ],
  2196. 'CREATED_AT' => 'PO.CREATED_AT',
  2197. 'CLOSED_AT' => 'PO.CLOSED_AT',
  2198. ]);
  2199. $condition = $filter['condition'];
  2200. $params = $filter['params'];
  2201. $form = new BonusExportForm();
  2202. $result = $form->run(['condition'=>$condition, 'params'=>$params], '业绩单');
  2203. if (!$result) {
  2204. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2205. }
  2206. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2207. }
  2208. /**
  2209. * 月积分
  2210. * @return mixed
  2211. * @throws \yii\base\Exception
  2212. * @throws HttpException
  2213. */
  2214. public function actionScoreMonth(){
  2215. $filter = $this->filterCondition([
  2216. 'USER_NAME' => 'U.USER_NAME',
  2217. 'userIds' => 'SM.USER_ID',
  2218. 'CALC_MONTH' => 'SM.CALC_MONTH',
  2219. 'CREATED_AT' => 'SM.CREATED_AT',
  2220. ]);
  2221. $condition = $filter['condition'];
  2222. $params = $filter['params'];
  2223. $listObj = new ScoreMonthList();
  2224. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2225. return static::notice($data);
  2226. }
  2227. /**
  2228. * 月积分导出
  2229. * @return mixed
  2230. * @throws \yii\db\Exception
  2231. * @throws HttpException
  2232. */
  2233. public function actionScoreMonthExport() {
  2234. $filter = $this->filterCondition([
  2235. 'USER_NAME' => 'U.USER_NAME',
  2236. 'userIds' => 'SM.USER_ID',
  2237. 'CALC_MONTH' => 'SM.CALC_MONTH',
  2238. 'CREATED_AT' => 'SM.CREATED_AT',
  2239. ]);
  2240. $condition = $filter['condition'];
  2241. $params = $filter['params'];
  2242. $form = new BonusExportForm();
  2243. $result = $form->run(['condition'=>$condition, 'params'=>$params], '月积分');
  2244. if (!$result) {
  2245. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2246. }
  2247. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2248. }
  2249. /**
  2250. * 月业绩
  2251. * @return mixed
  2252. * @throws \yii\base\Exception
  2253. * @throws HttpException
  2254. */
  2255. public function actionPerfMonth(){
  2256. $filter = $this->filterCondition([
  2257. 'USER_NAME' => 'U.USER_NAME',
  2258. 'REC_USER_NAME' => 'RU.USER_NAME',
  2259. 'userIds' => 'PM.USER_ID',
  2260. 'CALC_MONTH' => 'PM.CALC_MONTH',
  2261. 'CREATED_AT' => 'PM.CREATED_AT',
  2262. ]);
  2263. $condition = $filter['condition'];
  2264. $params = $filter['params'];
  2265. $listObj = new PerfMonthList();
  2266. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2267. return static::notice($data);
  2268. }
  2269. /**
  2270. * 月业绩导出
  2271. * @return mixed
  2272. * @throws \yii\db\Exception
  2273. * @throws HttpException
  2274. */
  2275. public function actionPerfMonthExport() {
  2276. $filter = $this->filterCondition([
  2277. 'USER_NAME' => 'U.USER_NAME',
  2278. 'REC_USER_NAME' => 'RU.USER_NAME',
  2279. 'userIds' => 'PM.USER_ID',
  2280. 'CALC_MONTH' => 'PM.CALC_MONTH',
  2281. 'CREATED_AT' => 'PM.CREATED_AT',
  2282. ]);
  2283. $condition = $filter['condition'];
  2284. $params = $filter['params'];
  2285. $form = new BonusExportForm();
  2286. $result = $form->run(['condition'=>$condition, 'params'=>$params], '月业绩');
  2287. if (!$result) {
  2288. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2289. }
  2290. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2291. }
  2292. /**
  2293. * 期业绩
  2294. * @return mixed
  2295. * @throws \yii\base\Exception
  2296. * @throws HttpException
  2297. */
  2298. public function actionPerfPeriodList(){
  2299. $filter = $this->filterCondition([
  2300. 'USER_NAME' => 'U.USER_NAME',
  2301. 'userIds' => 'PP.USER_ID',
  2302. 'PERIOD_NUM' => 'PP.PERIOD_NUM',
  2303. 'CREATED_AT' => 'PP.CREATED_AT',
  2304. ]);
  2305. $condition = $filter['condition'];
  2306. $params = $filter['params'];
  2307. $listObj = new PerfPeriodList();
  2308. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2309. return static::notice($data);
  2310. }
  2311. /**
  2312. * 期业绩导出
  2313. * @return mixed
  2314. * @throws \yii\db\Exception
  2315. * @throws HttpException
  2316. */
  2317. public function actionPerfPeriodListExport() {
  2318. $filter = $this->filterCondition([
  2319. 'USER_NAME' => 'U.USER_NAME',
  2320. 'userIds' => 'PP.USER_ID',
  2321. 'PERIOD_NUM' => 'PP.PERIOD_NUM',
  2322. 'CREATED_AT' => 'PP.CREATED_AT',
  2323. ]);
  2324. $condition = $filter['condition'];
  2325. $params = $filter['params'];
  2326. $form = new BonusExportForm();
  2327. $result = $form->run(['condition'=>$condition, 'params'=>$params], '期业绩');
  2328. if (!$result) {
  2329. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2330. }
  2331. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2332. }
  2333. /**
  2334. * 达标业绩
  2335. * @return mixed
  2336. * @throws \yii\base\Exception
  2337. * @throws HttpException
  2338. */
  2339. public function actionPerfStandard(){
  2340. $filter = $this->filterCondition([
  2341. 'USER_NAME' => 'U.USER_NAME',
  2342. 'REC_USER_NAME' => 'RU.USER_NAME',
  2343. 'userIds' => 'PS.USER_ID',
  2344. 'CALC_MONTH' => 'PS.CALC_MONTH',
  2345. 'CREATED_AT' => 'PS.CREATED_AT',
  2346. ]);
  2347. $condition = $filter['condition'];
  2348. $params = $filter['params'];
  2349. $listObj = new PerfStandardList();
  2350. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2351. return static::notice($data);
  2352. }
  2353. /**
  2354. * 达标业绩导出
  2355. * @return mixed
  2356. * @throws \yii\db\Exception
  2357. * @throws HttpException
  2358. */
  2359. public function actionPerfStandardExport() {
  2360. $filter = $this->filterCondition([
  2361. 'USER_NAME' => 'U.USER_NAME',
  2362. 'REC_USER_NAME' => 'RU.USER_NAME',
  2363. 'userIds' => 'PS.USER_ID',
  2364. 'CALC_MONTH' => 'PS.CALC_MONTH',
  2365. 'CREATED_AT' => 'PS.CREATED_AT',
  2366. ]);
  2367. $condition = $filter['condition'];
  2368. $params = $filter['params'];
  2369. $form = new BonusExportForm();
  2370. $result = $form->run(['condition'=>$condition, 'params'=>$params], '达标业绩');
  2371. if (!$result) {
  2372. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2373. }
  2374. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2375. }
  2376. /**
  2377. * 会员实时业绩
  2378. * @return mixed
  2379. * @throws HttpException
  2380. */
  2381. public function actionRealTimePerf() {
  2382. $userName = Yii::$app->request->get('userName');
  2383. if (!$userId = Info::getUserIdByUserName($userName)) {
  2384. return static::notice('Member does not exist', 400); // 会员不存在
  2385. }
  2386. $period = Period::instance();
  2387. $newPerf = Perf::getPeriodNewPerf($userId);
  2388. $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'])]];
  2389. $monthPerf = Perf::getMonthPerf($userId);
  2390. $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'])]];
  2391. $lastMonth = PerfMonth::getMonthPerf($period->getLastMonth()['yearMonth'], $userId);
  2392. $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'])]];
  2393. //是否合格
  2394. // $lastChkStatus = '';
  2395. // $lastMonthPerfChk = Cache::getSystemConfig()['lastMonthPerfChk']['VALUE'];
  2396. // $lastArr = [$lastMonth['PV_1L_TOTAL'], $lastMonth['PV_2L_TOTAL'], $lastMonth['PV_3L_TOTAL'], $lastMonth['PV_4L_TOTAL'], $lastMonth['PV_5L_TOTAL']];
  2397. // if (array_sum($lastArr) >= $lastMonthPerfChk) {
  2398. // $lastChkStatus = '已合格';
  2399. // }
  2400. //判断大区
  2401. // $bigLocation = array_search(max($lastArr), $lastArr) + 1;
  2402. return static::notice(['weekData' => $weekData, 'monthData' => $monthData, 'lastData' => $lastData]);
  2403. }
  2404. /**
  2405. * 荣衔业绩
  2406. * @return mixed
  2407. * @throws HttpException
  2408. */
  2409. public function actionYcPerf() {
  2410. $userName = Yii::$app->request->get('userName');
  2411. if (!$userId = Info::getUserIdByUserName($userName)) {
  2412. return static::notice('Member does not exist', 400); // 会员不存在
  2413. }
  2414. $userPerfData = Perf::getUserPerf($userId);
  2415. $ycPerfList = [];
  2416. //查找推荐的子会员
  2417. $childrenList = UserInfo::findUseDbCalc()->select('USER_ID')->where('REC_UID=:REC_UID', [
  2418. 'REC_UID' => $userId
  2419. ])->asArray()->all();
  2420. $maxPvPss = 0;
  2421. $childSumPerf = 0;
  2422. foreach ($childrenList as $child) {
  2423. $childBaseUser = Info::getBaseUserById($child['USER_ID']);
  2424. if( !$childBaseUser ) continue;
  2425. $childPerfData = Perf::getUserPerf($child['USER_ID']);
  2426. if( !$childPerfData ) continue;
  2427. $childPvPcs = $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'];
  2428. $childPvPssTotal = $childPvPcs + $childPerfData['PV_PSS'];
  2429. $childSumPerf += $childPvPssTotal;
  2430. if( $childPvPssTotal >= $maxPvPss ) {
  2431. $maxPvPss = $childPvPssTotal;
  2432. }
  2433. $ycPerfList[] = [
  2434. 'USER_NAME'=>$childBaseUser['USER_NAME'],
  2435. 'REAL_NAME'=>$childBaseUser['REAL_NAME'],
  2436. 'PV_PCS' => $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'],
  2437. 'PV_PSS_TOTAL' => $childPerfData['PV_PSS_TOTAL'],
  2438. 'MAX_DEPART_PERF' => '-',
  2439. 'OTHER_DEPART_PERF' => '-',
  2440. 'PV_PSS_SUM_TOTAL' => round($childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'] + $childPerfData['PV_PSS_TOTAL'],2),
  2441. ];
  2442. }
  2443. if( $userPerfData ) {
  2444. $baseUser = Info::getBaseUserById($userId);
  2445. $ycPerfData = [
  2446. 'USER_NAME'=>$baseUser['USER_NAME'],
  2447. 'REAL_NAME'=>$baseUser['REAL_NAME'],
  2448. 'PV_PCS' => $userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'],
  2449. 'PV_PSS_TOTAL' => $userPerfData['PV_PSS_TOTAL'],
  2450. 'MAX_DEPART_PERF' => round($maxPvPss, 2),
  2451. 'OTHER_DEPART_PERF' => round($childSumPerf-$maxPvPss, 2),
  2452. 'PV_PSS_SUM_TOTAL' => round($userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'] + $userPerfData['PV_PSS_TOTAL'],2),
  2453. ];
  2454. array_unshift($ycPerfList, $ycPerfData);
  2455. }
  2456. return static::notice(['ycPerfList' => $ycPerfList]);
  2457. }
  2458. /**
  2459. * 用户业绩
  2460. * @return mixed
  2461. * @throws HttpException
  2462. */
  2463. public function actionUserPerf() {
  2464. $filter = $this->filterCondition([
  2465. 'USER_NAME' => 'U.USER_NAME',
  2466. ]);
  2467. $condition = $filter['condition'];
  2468. $params = $filter['params'];
  2469. $listObj = new UserPerfList();
  2470. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2471. return static::notice($data);
  2472. }
  2473. /**
  2474. * 月业绩导出
  2475. * @return mixed
  2476. * @throws \yii\db\Exception
  2477. * @throws HttpException
  2478. */
  2479. public function actionUserPerfExport() {
  2480. $filter = $this->filterCondition([
  2481. 'USER_NAME' => 'U.USER_NAME',
  2482. ]);
  2483. $condition = $filter['condition'];
  2484. $params = $filter['params'];
  2485. $form = new BonusExportForm();
  2486. $result = $form->run(['condition'=>$condition, 'params'=>$params], '用户业绩');
  2487. if (!$result) {
  2488. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2489. }
  2490. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2491. }
  2492. /**
  2493. * 自动提现(奖金)
  2494. *
  2495. */
  2496. public function actionAutoWithdraw() {
  2497. $withdrawLock = Cache::getWithdrawLock();
  2498. if ($withdrawLock!=0){
  2499. return static::notice(Form::formatErrorsForApi('已有进程在生成'), 400);
  2500. }else{
  2501. $formModel = new UserBonusForm();
  2502. $formModel->scenario = 'autoWithdraw';
  2503. if ($formModel->autoWithdrawWebToAsync()) {
  2504. return static::notice('生成提现单 已开始处理,请等待');
  2505. } else {
  2506. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2507. }
  2508. }
  2509. }
  2510. /**
  2511. * 查询安置网下级会员和业绩、修改业绩
  2512. * @return mixed|void
  2513. * @throws HttpException
  2514. * @throws \yii\base\Exception
  2515. */
  2516. public function actionPerfAdjustment()
  2517. {
  2518. // 查询业绩
  2519. if (\Yii::$app->request->isGet) {
  2520. $memberCode = Yii::$app->request->get('memberCode');
  2521. $userId = Info::getUserIdByUserName(trim($memberCode));
  2522. // 查询传入会员业绩
  2523. $perfMarket = UserPerf::getPerfMarket($userId);
  2524. if ($perfMarket) {
  2525. // 查询传入会员的安置网下级
  2526. $memberList = UserNetwork::getFirstFloorChildren($userId);
  2527. $memberList = array_column($memberList, NULL, 'RELATIVE_LOCATION');
  2528. // 左腿1市场
  2529. $leftPerfUserName = (isset($memberList[1]) && $memberList[1]['USER_ID']) ? Info::getUserNameByUserId($memberList[1]['USER_ID']) : '';
  2530. // 右腿2市场
  2531. $rightPerfUserName = (isset($memberList[2]) && $memberList[2]['USER_ID']) ? Info::getUserNameByUserId($memberList[2]['USER_ID']) : '';
  2532. // 会员编号
  2533. $perfMarket['USER_NAME'] = $memberCode;
  2534. $perfMarket['SURPLUS_1L_USER_NAME'] = $leftPerfUserName;
  2535. $perfMarket['SURPLUS_2L_USER_NAME'] = $rightPerfUserName;
  2536. return static::notice(['allData' => $perfMarket]);
  2537. }
  2538. return static::notice('No data', 400);
  2539. } else if (\Yii::$app->request->isPost) {
  2540. $formModel = new PerfAdjustmentForm();
  2541. $formModel->scenario = 'perfAdjustment';
  2542. $post = \Yii::$app->request->post();
  2543. if ($formModel->load($post, '') && $formModel->perfAdjustment()) {
  2544. return static::notice('Successful');
  2545. } else {
  2546. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2547. }
  2548. } else {
  2549. return static::notice('Illegal request', 400); // 非法请求
  2550. }
  2551. }
  2552. }