BonusController.php 103 KB

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