BonusController.php 102 KB

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