BonusController.php 103 KB

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