BonusController.php 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760
  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_GL',
  766. 'BONUS_QY' => 'CB.BONUS_QY',
  767. 'BONUS_YC' => 'CB.BONUS_YC',
  768. 'PV_1L' => 'CB.PV_1L',
  769. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  770. 'PV_2L' => 'CB.PV_2L',
  771. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  772. 'PV_3L' => 'CB.PV_3L',
  773. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  774. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  775. 'CALC_MONTH' => 'CB.CALC_MONTH',
  776. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  777. ]);
  778. $periodNum = Period::calculatedMaxPeriodNum();
  779. $period = Period::instance();
  780. $yearMonth = $period->getYearMonth($periodNum);
  781. $filter['condition'] .= ' AND PERIOD_NUM=:PERIOD_NUM';
  782. $filter['params'][':PERIOD_NUM'] = $periodNum;
  783. $form = new BonusExportForm();
  784. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth]]), '最新奖金');
  785. if (!$result) {
  786. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  787. }
  788. return static::notice('导出开始,请到文件管理-导出文件查看');
  789. }
  790. /**
  791. * 获取往期已结算的奖金
  792. * @return mixed
  793. * @throws \yii\db\Exception
  794. * @throws \yii\web\HttpException
  795. */
  796. public function actionOtherPeriodBonus() {
  797. $periodNumRequest = \Yii::$app->request->get('periodNum');
  798. if(!$periodNumRequest){
  799. $periodNum = Period::calculatedMaxPeriodNum();
  800. //return static::notice('请填写期数',400);
  801. }else{
  802. $periodNum = explode(",", $periodNumRequest)[1];
  803. }
  804. $data = $this->_periodBonus($periodNum,false);
  805. if( isset($data['filterTypes']) && is_array($data['filterTypes']) ) {
  806. $data['filterTypes'] = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> '结算期数']], $data['filterTypes']);
  807. }
  808. return static::notice($data);
  809. }
  810. /**
  811. * 往期奖金导出
  812. * @return mixed
  813. * @throws \yii\db\Exception
  814. * @throws \yii\web\HttpException
  815. */
  816. public function actionOtherPeriodBonusExport() {
  817. $filter = $this->filterCondition([
  818. 'periodNum' => 'CB.PERIOD_NUM',
  819. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  820. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  821. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  822. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  823. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  824. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  825. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  826. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  827. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  828. 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  829. 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  830. 'BONUS_BD' => 'CB.BONUS_BD',
  831. 'BONUS_TG' => 'CB.BONUS_TG',
  832. 'BONUS_YJ' => 'CB.BONUS_YJ',
  833. 'BONUS_GX' => 'CB.BONUS_GX',
  834. 'BONUS_GL' => 'CB.BONUS_GL',
  835. 'BONUS_QY' => 'CB.BONUS_QY',
  836. 'BONUS_YC' => 'CB.BONUS_YC',
  837. 'PV_1L' => 'CB.PV_1L',
  838. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  839. 'PV_2L' => 'CB.PV_2L',
  840. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  841. 'PV_3L' => 'CB.PV_3L',
  842. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  843. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  844. 'CALC_MONTH' => 'CB.CALC_MONTH',
  845. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  846. ]);
  847. $periodNumRequest = \Yii::$app->request->get('periodNum');
  848. if(!$periodNumRequest){
  849. $periodNum = Period::calculatedMaxPeriodNum();
  850. }else{
  851. $periodNum = explode(",", $periodNumRequest)[1];
  852. }
  853. // if(!isset($filter['params'][':PERIODNUM'])){
  854. // return static::notice('请填写期数',400);
  855. // }
  856. // $periodNum = $filter['params'][':PERIODNUM'];
  857. $period = Period::instance();
  858. $yearMonth = $period->getYearMonth($periodNum);
  859. // $filter['condition'] .= ' AND CB.PERIOD_NUM=:PERIOD_NUM';
  860. // $filter['params'][':PERIOD_NUM'] = $periodNum;
  861. $form = new BonusExportForm();
  862. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth]]), '往期奖金');
  863. if (!$result) {
  864. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  865. }
  866. return static::notice('导出开始,请到文件管理-导出文件查看');
  867. }
  868. /**
  869. * 获取筛选类型
  870. * @return mixed
  871. * @throws \yii\web\HttpException
  872. */
  873. public function actionOtherPeriodBonusFilterTypes(){
  874. $listObj = new PeriodBonusList();
  875. $filterTypes = $listObj->getFilterTypes();
  876. $filterTypes = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> '结算期数']], $filterTypes);
  877. return static::notice($filterTypes);
  878. }
  879. /**
  880. * 期数对应的奖金
  881. * @param $periodNum
  882. * @param $periodFilter
  883. * @return array
  884. * @throws \yii\base\Exception
  885. * @throws \yii\db\Exception
  886. */
  887. private function _periodBonus($periodNum,$periodFilter = true) {
  888. $filter = $this->filterCondition([
  889. 'periodNum' => 'CB.PERIOD_NUM',
  890. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  891. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  892. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  893. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  894. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  895. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  896. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  897. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  898. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  899. 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  900. 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  901. 'BONUS_BD' => 'CB.BONUS_BD',
  902. 'BONUS_TG' => 'CB.BONUS_TG',
  903. 'BONUS_XF' => 'CB.BONUS_XF',
  904. 'BONUS_YJ' => 'CB.BONUS_YJ',
  905. 'BONUS_GX' => 'CB.BONUS_GX',
  906. 'BONUS_GL' => 'CB.BONUS_GL',
  907. 'BONUS_QY' => 'CB.BONUS_QY',
  908. 'BONUS_YC' => 'CB.BONUS_YC',
  909. 'ORI_BONUS_STANDARD' => 'CB.ORI_BONUS_STANDARD',
  910. 'PV_1L' => 'CB.PV_1L',
  911. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  912. 'PV_2L' => 'CB.PV_2L',
  913. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  914. 'PV_3L' => 'CB.PV_3L',
  915. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  916. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  917. 'CALC_MONTH' => 'CB.CALC_MONTH',
  918. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  919. ]);
  920. $period = Period::instance();
  921. $yearMonth = $period->getYearMonth($periodNum);
  922. $condition = $filter['condition'];
  923. $params = $filter['params'];
  924. if($periodFilter){
  925. $condition .= ' AND CB.PERIOD_NUM=:PERIOD_NUM';
  926. $params[':PERIOD_NUM'] = $periodNum;
  927. }
  928. $listObj = new PeriodBonusList();
  929. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth]]);
  930. return $data;
  931. }
  932. /**
  933. * 团队奖奖金向下追溯
  934. * @return mixed
  935. * @throws \yii\base\Exception
  936. * @throws \yii\db\Exception
  937. * @throws \yii\web\HttpException
  938. */
  939. public function actionTraceDownQy() {
  940. $periodNum = Yii::$app->request->get('periodNum');
  941. if (!$periodNum) return static::notice('请填写期数', 400);
  942. $userName = Yii::$app->request->get('userName');
  943. if (!$userName) return static::notice('请填写会员编号', 400);
  944. $period = Period::instance();
  945. if (!$period->isCalculated($periodNum)) {
  946. return static::notice([]);
  947. }
  948. $yearMonth = $period->getYearMonth($periodNum);
  949. $filter = $this->filterCondition([
  950. 'decType' => 'PO.DEC_TYPE',
  951. 'periodNum' => 'PO.PERIOD_NUM',
  952. ]);
  953. $qyFilter = $this->_qyFilterCondition($filter['request']);
  954. $filter = array_merge($filter, $qyFilter);
  955. $condition = $filter['condition'];
  956. $params = $filter['params'];
  957. $listObj = new TraceDownQyList();
  958. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  959. return static::notice($data);
  960. }
  961. /**
  962. * 获取
  963. * @param $request
  964. * @return array|string[]
  965. */
  966. private function _qyFilterCondition($request) {
  967. //根据USER_NAME获取USER_ID
  968. $user = User::find()->select('ID')->where('USER_NAME=:USER_NAME', ['USER_NAME'=>$request['userName']])->asArray()->one();
  969. if( !$user ) return [];
  970. //找到这个会员的LOCATION_TAG
  971. $userNetwork = UserNetwork::find()->select(['LOCATION_TAG'])->where('USER_ID=:USER_ID', ['USER_ID'=>$user['ID']])->asArray()->one();
  972. $searchLocationTag = $userNetwork['LOCATION_TAG'];
  973. if( isset($request['location']) && $request['location'] ) {
  974. $searchLocationTag .= $request['location'];
  975. }
  976. return [
  977. 'LOCATION_TAG' => 'LIKE ' . $searchLocationTag . '%'
  978. ];
  979. }
  980. /**
  981. * 团队奖向下追溯导出
  982. * @return mixed
  983. * @throws \yii\db\Exception
  984. * @throws \yii\web\HttpException
  985. */
  986. public function actionTraceDownQyExport() {
  987. $periodNum = Yii::$app->request->get('periodNum');
  988. if (!$periodNum) return static::notice('请填写期数', 400);
  989. $userName = Yii::$app->request->get('userName');
  990. if (!$userName) return static::notice('请填写会员编号', 400);
  991. $period = Period::instance();
  992. if (!$period->isCalculated($periodNum)) {
  993. return static::notice([]);
  994. }
  995. $yearMonth = $period->getYearMonth($periodNum);
  996. $filter = $this->filterCondition([
  997. 'decType' => 'PO.DEC_TYPE',
  998. 'periodNum' => 'PO.PERIOD_NUM',
  999. ]);
  1000. $qyFilter = $this->_qyFilterCondition($filter['request']);
  1001. $filter = array_merge($filter, $qyFilter);
  1002. $form = new BonusExportForm();
  1003. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '团队奖向下追溯');
  1004. if (!$result) {
  1005. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1006. }
  1007. return static::notice('导出开始,请到文件管理-导出文件查看');
  1008. }
  1009. /**
  1010. * 团队奖向上追溯
  1011. * @return mixed
  1012. * @throws \yii\base\Exception
  1013. * @throws \yii\web\HttpException
  1014. */
  1015. public function actionTraceUpQy() {
  1016. $periodNum = Yii::$app->request->get('periodNum');
  1017. if (!$periodNum) return static::notice('请填写期数', 400);
  1018. if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
  1019. if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('会员不存在', 400);
  1020. //会员是否有业绩单
  1021. if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
  1022. return static::notice('该会员本期没有业绩单', 400);
  1023. }
  1024. $listObj = new TraceUpQyList();
  1025. $data = $listObj->getList(['condition'=>'', 'params'=>[], 'others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]);
  1026. return static::notice($data);
  1027. }
  1028. /**
  1029. * 团队奖向上追溯导出
  1030. * @return mixed
  1031. * @throws \yii\db\Exception
  1032. * @throws \yii\web\HttpException
  1033. */
  1034. public function actionTraceUpQyExport() {
  1035. $periodNum = Yii::$app->request->get('periodNum');
  1036. if (!$periodNum) return static::notice('请填写期数', 400);
  1037. if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
  1038. if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('会员不存在', 400);
  1039. //会员是否有业绩单
  1040. if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
  1041. return static::notice('该会员本期没有业绩单', 400);
  1042. }
  1043. $form = new BonusExportForm();
  1044. $result = $form->run(array_merge(['condition'=>'', 'params'=>[]], ['others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]), '团队奖向上追溯');
  1045. if (!$result) {
  1046. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1047. }
  1048. return static::notice('导出开始,请到文件管理-导出文件查看');
  1049. }
  1050. /**
  1051. * 荣衔奖向下追溯
  1052. * @return mixed
  1053. * @throws \yii\base\Exception
  1054. * @throws \yii\db\Exception
  1055. * @throws \yii\web\HttpException
  1056. */
  1057. public function actionTraceDownYc() {
  1058. $periodNum = Yii::$app->request->get('periodNum');
  1059. if (!$periodNum) return static::notice([]);
  1060. $period = Period::instance();
  1061. $yearMonth = $period->getYearMonth($periodNum);
  1062. $filter = $this->filterCondition([
  1063. 'userName' => 'UI.USER_NAME',
  1064. 'periodNum' => 'CBY.PERIOD_NUM',
  1065. ]);
  1066. $condition = $filter['condition'];
  1067. $params = $filter['params'];
  1068. $listObj = new TraceDownYcList();
  1069. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1070. return static::notice($data);
  1071. }
  1072. /**
  1073. * 荣衔奖向下追溯导出
  1074. * @return mixed
  1075. * @throws \yii\db\Exception
  1076. * @throws \yii\web\HttpException
  1077. */
  1078. public function actionTraceDownYcExport() {
  1079. $periodNum = Yii::$app->request->get('periodNum');
  1080. if (!$periodNum) return static::notice([]);
  1081. $period = Period::instance();
  1082. $yearMonth = $period->getYearMonth($periodNum);
  1083. $filter = $this->filterCondition([
  1084. 'userName' => 'UI.USER_NAME',
  1085. 'periodNum' => 'CBY.PERIOD_NUM',
  1086. ]);
  1087. $form = new BonusExportForm();
  1088. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向下追溯');
  1089. if (!$result) {
  1090. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1091. }
  1092. return static::notice('导出开始,请到文件管理-导出文件查看');
  1093. }
  1094. /**
  1095. * 服务奖向下追溯
  1096. * @return mixed
  1097. * @throws \yii\base\Exception
  1098. * @throws \yii\db\Exception
  1099. * @throws \yii\web\HttpException
  1100. */
  1101. public function actionTraceDownBd() {
  1102. $periodNum = Yii::$app->request->get('periodNum');
  1103. if (!$periodNum) return static::notice([]);
  1104. $period = Period::instance();
  1105. $yearMonth = $period->getYearMonth($periodNum);
  1106. $filter = $this->filterCondition([
  1107. 'userName' => 'UI.USER_NAME',
  1108. 'periodNum' => 'CBB.PERIOD_NUM',
  1109. ]);
  1110. $condition = $filter['condition'];
  1111. $params = $filter['params'];
  1112. $listObj = new TraceDownBdList();
  1113. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1114. return static::notice($data);
  1115. }
  1116. /**
  1117. * 服务奖向下追溯导出
  1118. * @return mixed
  1119. * @throws \yii\db\Exception
  1120. * @throws \yii\web\HttpException
  1121. */
  1122. public function actionTraceDownBdExport() {
  1123. $periodNum = Yii::$app->request->get('periodNum');
  1124. if (!$periodNum) return static::notice([]);
  1125. $period = Period::instance();
  1126. $yearMonth = $period->getYearMonth($periodNum);
  1127. $filter = $this->filterCondition([
  1128. 'userName' => 'UI.USER_NAME',
  1129. 'periodNum' => 'CBB.PERIOD_NUM',
  1130. ]);
  1131. $form = new BonusExportForm();
  1132. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '服务奖向下追溯');
  1133. if (!$result) {
  1134. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1135. }
  1136. return static::notice('导出开始,请到文件管理-导出文件查看');
  1137. }
  1138. /**
  1139. * 推广奖向下追溯
  1140. * @return mixed
  1141. * @throws \yii\base\Exception
  1142. * @throws \yii\db\Exception
  1143. * @throws \yii\web\HttpException
  1144. */
  1145. public function actionTraceDownTg() {
  1146. $periodNum = Yii::$app->request->get('periodNum');
  1147. if (!$periodNum) return static::notice([]);
  1148. $period = Period::instance();
  1149. $yearMonth = $period->getYearMonth($periodNum);
  1150. $filter = $this->filterCondition([
  1151. 'userName' => 'UI.USER_NAME',
  1152. 'periodNum' => 'CTG.PERIOD_NUM',
  1153. ]);
  1154. $condition = $filter['condition'];
  1155. $params = $filter['params'];
  1156. $listObj = new TraceDownTgList();
  1157. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1158. return static::notice($data);
  1159. }
  1160. /**
  1161. * 推广奖向下追溯导出
  1162. * @return mixed
  1163. * @throws \yii\db\Exception
  1164. * @throws \yii\web\HttpException
  1165. */
  1166. public function actionTraceDownTgExport() {
  1167. $periodNum = Yii::$app->request->get('periodNum');
  1168. if (!$periodNum) return static::notice([]);
  1169. $period = Period::instance();
  1170. $yearMonth = $period->getYearMonth($periodNum);
  1171. $filter = $this->filterCondition([
  1172. 'userName' => 'UI.USER_NAME',
  1173. 'periodNum' => 'CTG.PERIOD_NUM',
  1174. ]);
  1175. $form = new BonusExportForm();
  1176. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '推广奖向下追溯');
  1177. if (!$result) {
  1178. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1179. }
  1180. return static::notice('导出开始,请到文件管理-导出文件查看');
  1181. }
  1182. /**
  1183. * 消费奖向下追溯
  1184. * @return mixed
  1185. * @throws \yii\base\Exception
  1186. * @throws \yii\db\Exception
  1187. * @throws \yii\web\HttpException
  1188. */
  1189. public function actionTraceDownXf() {
  1190. $periodNum = Yii::$app->request->get('periodNum');
  1191. if (!$periodNum) return static::notice([]);
  1192. $period = Period::instance();
  1193. $yearMonth = $period->getYearMonth($periodNum);
  1194. $filter = $this->filterCondition([
  1195. 'userName' => 'UI.USER_NAME',
  1196. 'periodNum' => 'CXF.PERIOD_NUM',
  1197. ]);
  1198. $condition = $filter['condition'];
  1199. $params = $filter['params'];
  1200. $listObj = new TraceDownXfList();
  1201. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1202. return static::notice($data);
  1203. }
  1204. /**
  1205. * 消费奖向下追溯导出
  1206. * @return mixed
  1207. * @throws \yii\db\Exception
  1208. * @throws \yii\web\HttpException
  1209. */
  1210. public function actionTraceDownXfExport() {
  1211. $periodNum = Yii::$app->request->get('periodNum');
  1212. if (!$periodNum) return static::notice([]);
  1213. $period = Period::instance();
  1214. $yearMonth = $period->getYearMonth($periodNum);
  1215. $filter = $this->filterCondition([
  1216. 'userName' => 'UI.USER_NAME',
  1217. 'periodNum' => 'CXF.PERIOD_NUM',
  1218. ]);
  1219. $form = new BonusExportForm();
  1220. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '推广奖向下追溯');
  1221. if (!$result) {
  1222. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1223. }
  1224. return static::notice('导出开始,请到文件管理-导出文件查看');
  1225. }
  1226. /**
  1227. * 业绩奖向下追溯
  1228. * @return mixed
  1229. * @throws \yii\base\Exception
  1230. * @throws \yii\db\Exception
  1231. * @throws \yii\web\HttpException
  1232. */
  1233. public function actionTraceDownYj() {
  1234. $periodNum = Yii::$app->request->get('periodNum');
  1235. if (!$periodNum) return static::notice([]);
  1236. $period = Period::instance();
  1237. $yearMonth = $period->getYearMonth($periodNum);
  1238. $filter = $this->filterCondition([
  1239. 'userName' => 'UI.USER_NAME',
  1240. 'periodNum' => 'CYJ.PERIOD_NUM',
  1241. ]);
  1242. $condition = $filter['condition'];
  1243. $params = $filter['params'];
  1244. $listObj = new TraceDownYjList();
  1245. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1246. return static::notice($data);
  1247. }
  1248. /**
  1249. * 业绩奖向下追溯导出
  1250. * @return mixed
  1251. * @throws \yii\db\Exception
  1252. * @throws \yii\web\HttpException
  1253. */
  1254. public function actionTraceDownYjExport() {
  1255. $periodNum = Yii::$app->request->get('periodNum');
  1256. if (!$periodNum) return static::notice([]);
  1257. $period = Period::instance();
  1258. $yearMonth = $period->getYearMonth($periodNum);
  1259. $filter = $this->filterCondition([
  1260. 'userName' => 'UI.USER_NAME',
  1261. 'periodNum' => 'CYJ.PERIOD_NUM',
  1262. ]);
  1263. $form = new BonusExportForm();
  1264. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '业绩奖向下追溯');
  1265. if (!$result) {
  1266. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1267. }
  1268. return static::notice('导出开始,请到文件管理-导出文件查看');
  1269. }
  1270. /**
  1271. * 共享奖向下追溯
  1272. * @return mixed
  1273. * @throws \yii\base\Exception
  1274. * @throws \yii\db\Exception
  1275. * @throws \yii\web\HttpException
  1276. */
  1277. public function actionTraceDownGx() {
  1278. $periodNum = Yii::$app->request->get('periodNum');
  1279. if (!$periodNum) return static::notice([]);
  1280. $period = Period::instance();
  1281. $yearMonth = $period->getYearMonth($periodNum);
  1282. $filter = $this->filterCondition([
  1283. 'userName' => 'UI.USER_NAME',
  1284. 'periodNum' => 'CGX.PERIOD_NUM',
  1285. ]);
  1286. $condition = $filter['condition'];
  1287. $params = $filter['params'];
  1288. $listObj = new TraceDownGxList();
  1289. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1290. return static::notice($data);
  1291. }
  1292. /**
  1293. * 共享奖向下追溯导出
  1294. * @return mixed
  1295. * @throws \yii\db\Exception
  1296. * @throws \yii\web\HttpException
  1297. */
  1298. public function actionTraceDownGxExport() {
  1299. $periodNum = Yii::$app->request->get('periodNum');
  1300. if (!$periodNum) return static::notice([]);
  1301. $period = Period::instance();
  1302. $yearMonth = $period->getYearMonth($periodNum);
  1303. $filter = $this->filterCondition([
  1304. 'userName' => 'UI.USER_NAME',
  1305. 'periodNum' => 'CGX.PERIOD_NUM',
  1306. ]);
  1307. $form = new BonusExportForm();
  1308. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '共享奖向下追溯');
  1309. if (!$result) {
  1310. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1311. }
  1312. return static::notice('导出开始,请到文件管理-导出文件查看');
  1313. }
  1314. /**
  1315. * 管理奖向下追溯
  1316. * @return mixed
  1317. * @throws \yii\base\Exception
  1318. * @throws \yii\db\Exception
  1319. * @throws \yii\web\HttpException
  1320. */
  1321. public function actionTraceDownGl() {
  1322. $periodNum = Yii::$app->request->get('periodNum');
  1323. if (!$periodNum) return static::notice([]);
  1324. $period = Period::instance();
  1325. $yearMonth = $period->getYearMonth($periodNum);
  1326. $filter = $this->filterCondition([
  1327. 'userName' => 'UI.USER_NAME',
  1328. 'periodNum' => 'CGL.PERIOD_NUM',
  1329. ]);
  1330. $condition = $filter['condition'];
  1331. $params = $filter['params'];
  1332. $listObj = new TraceDownGlList();
  1333. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1334. return static::notice($data);
  1335. }
  1336. /**
  1337. * 管理奖向下追溯导出
  1338. * @return mixed
  1339. * @throws \yii\db\Exception
  1340. * @throws \yii\web\HttpException
  1341. */
  1342. public function actionTraceDownGlExport() {
  1343. $periodNum = Yii::$app->request->get('periodNum');
  1344. if (!$periodNum) return static::notice([]);
  1345. $period = Period::instance();
  1346. $yearMonth = $period->getYearMonth($periodNum);
  1347. $filter = $this->filterCondition([
  1348. 'userName' => 'UI.USER_NAME',
  1349. 'periodNum' => 'CGL.PERIOD_NUM',
  1350. ]);
  1351. $form = new BonusExportForm();
  1352. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '管理奖向下追溯');
  1353. if (!$result) {
  1354. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1355. }
  1356. return static::notice('导出开始,请到文件管理-导出文件查看');
  1357. }
  1358. /**
  1359. * 荣衔奖向上追溯
  1360. * @return mixed
  1361. * @throws \yii\base\Exception
  1362. * @throws \yii\db\Exception
  1363. * @throws \yii\web\HttpException
  1364. */
  1365. public function actionTraceUpYc() {
  1366. $periodNum = Yii::$app->request->get('periodNum');
  1367. if (!$periodNum) return static::notice([]);
  1368. $period = Period::instance();
  1369. $yearMonth = $period->getYearMonth($periodNum);
  1370. $filter = $this->filterCondition([
  1371. 'userName' => 'UI.USER_NAME',
  1372. 'periodNum' => 'CBY.PERIOD_NUM',
  1373. ]);
  1374. $condition = $filter['condition'];
  1375. $params = $filter['params'];
  1376. $listObj = new TraceUpYcList();
  1377. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1378. return static::notice($data);
  1379. }
  1380. /**
  1381. * 荣衔奖向上追溯导出
  1382. * @return mixed
  1383. * @throws \yii\db\Exception
  1384. * @throws \yii\web\HttpException
  1385. */
  1386. public function actionTraceUpYcExport() {
  1387. $periodNum = Yii::$app->request->get('periodNum');
  1388. if (!$periodNum) return static::notice([]);
  1389. $period = Period::instance();
  1390. $yearMonth = $period->getYearMonth($periodNum);
  1391. $filter = $this->filterCondition([
  1392. 'userName' => 'UI.USER_NAME',
  1393. 'periodNum' => 'CBY.PERIOD_NUM',
  1394. ]);
  1395. $form = new BonusExportForm();
  1396. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1397. if (!$result) {
  1398. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1399. }
  1400. return static::notice('导出开始,请到文件管理-导出文件查看');
  1401. }
  1402. /**
  1403. * 服务奖向上追溯
  1404. * @return mixed
  1405. * @throws \yii\base\Exception
  1406. * @throws \yii\db\Exception
  1407. * @throws \yii\web\HttpException
  1408. */
  1409. public function actionTraceUpBd() {
  1410. $periodNum = Yii::$app->request->get('periodNum');
  1411. if (!$periodNum) return static::notice([]);
  1412. $period = Period::instance();
  1413. $yearMonth = $period->getYearMonth($periodNum);
  1414. $filter = $this->filterCondition([
  1415. 'userName' => 'UI.USER_NAME',
  1416. 'periodNum' => 'CBB.PERIOD_NUM',
  1417. ]);
  1418. $condition = $filter['condition'];
  1419. $params = $filter['params'];
  1420. $listObj = new TraceUpBdList();
  1421. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1422. return static::notice($data);
  1423. }
  1424. /**
  1425. * 服务奖向上追溯导出
  1426. * @return mixed
  1427. * @throws \yii\db\Exception
  1428. * @throws \yii\web\HttpException
  1429. */
  1430. public function actionTraceUpBdExport() {
  1431. $periodNum = Yii::$app->request->get('periodNum');
  1432. if (!$periodNum) return static::notice([]);
  1433. $period = Period::instance();
  1434. $yearMonth = $period->getYearMonth($periodNum);
  1435. $filter = $this->filterCondition([
  1436. 'userName' => 'UI.USER_NAME',
  1437. 'periodNum' => 'CBY.PERIOD_NUM',
  1438. ]);
  1439. $form = new BonusExportForm();
  1440. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1441. if (!$result) {
  1442. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1443. }
  1444. return static::notice('导出开始,请到文件管理-导出文件查看');
  1445. }
  1446. /**
  1447. * 推广奖向上追溯
  1448. * @return mixed
  1449. * @throws \yii\base\Exception
  1450. * @throws \yii\db\Exception
  1451. * @throws \yii\web\HttpException
  1452. */
  1453. public function actionTraceUpTg() {
  1454. $periodNum = Yii::$app->request->get('periodNum');
  1455. if (!$periodNum) return static::notice([]);
  1456. $period = Period::instance();
  1457. $yearMonth = $period->getYearMonth($periodNum);
  1458. $filter = $this->filterCondition([
  1459. 'userName' => 'UI.USER_NAME',
  1460. 'periodNum' => 'CTG.PERIOD_NUM',
  1461. ]);
  1462. $condition = $filter['condition'];
  1463. $params = $filter['params'];
  1464. $listObj = new TraceUpTgList();
  1465. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1466. return static::notice($data);
  1467. }
  1468. /**
  1469. * 推广奖向上追溯导出
  1470. * @return mixed
  1471. * @throws \yii\db\Exception
  1472. * @throws \yii\web\HttpException
  1473. */
  1474. public function actionTraceUpTgExport() {
  1475. $periodNum = Yii::$app->request->get('periodNum');
  1476. if (!$periodNum) return static::notice([]);
  1477. $period = Period::instance();
  1478. $yearMonth = $period->getYearMonth($periodNum);
  1479. $filter = $this->filterCondition([
  1480. 'userName' => 'UI.USER_NAME',
  1481. 'periodNum' => 'CTG.PERIOD_NUM',
  1482. ]);
  1483. $form = new BonusExportForm();
  1484. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1485. if (!$result) {
  1486. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1487. }
  1488. return static::notice('导出开始,请到文件管理-导出文件查看');
  1489. }
  1490. /**
  1491. * 消费奖向上追溯
  1492. * @return mixed
  1493. * @throws \yii\base\Exception
  1494. * @throws \yii\db\Exception
  1495. * @throws \yii\web\HttpException
  1496. */
  1497. public function actionTraceUpXf() {
  1498. $periodNum = Yii::$app->request->get('periodNum');
  1499. if (!$periodNum) return static::notice([]);
  1500. $period = Period::instance();
  1501. $yearMonth = $period->getYearMonth($periodNum);
  1502. $filter = $this->filterCondition([
  1503. 'userName' => 'UI.USER_NAME',
  1504. 'periodNum' => 'CXF.PERIOD_NUM',
  1505. ]);
  1506. $condition = $filter['condition'];
  1507. $params = $filter['params'];
  1508. $listObj = new TraceUpXfList();
  1509. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1510. return static::notice($data);
  1511. }
  1512. /**
  1513. * 推广奖向上追溯导出
  1514. * @return mixed
  1515. * @throws \yii\db\Exception
  1516. * @throws \yii\web\HttpException
  1517. */
  1518. public function actionTraceUpXfExport() {
  1519. $periodNum = Yii::$app->request->get('periodNum');
  1520. if (!$periodNum) return static::notice([]);
  1521. $period = Period::instance();
  1522. $yearMonth = $period->getYearMonth($periodNum);
  1523. $filter = $this->filterCondition([
  1524. 'userName' => 'UI.USER_NAME',
  1525. 'periodNum' => 'CXF.PERIOD_NUM',
  1526. ]);
  1527. $form = new BonusExportForm();
  1528. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1529. if (!$result) {
  1530. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1531. }
  1532. return static::notice('导出开始,请到文件管理-导出文件查看');
  1533. }
  1534. /**
  1535. * 业绩奖向上追溯
  1536. * @return mixed
  1537. * @throws \yii\base\Exception
  1538. * @throws \yii\db\Exception
  1539. * @throws \yii\web\HttpException
  1540. */
  1541. public function actionTraceUpYj() {
  1542. $periodNum = Yii::$app->request->get('periodNum');
  1543. if (!$periodNum) return static::notice([]);
  1544. $period = Period::instance();
  1545. $yearMonth = $period->getYearMonth($periodNum);
  1546. $filter = $this->filterCondition([
  1547. 'userName' => 'UI.USER_NAME',
  1548. 'periodNum' => 'CYJ.PERIOD_NUM',
  1549. ]);
  1550. $condition = $filter['condition'];
  1551. $params = $filter['params'];
  1552. $listObj = new TraceUpYjList();
  1553. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1554. return static::notice($data);
  1555. }
  1556. /**
  1557. * 业绩奖向上追溯导出
  1558. * @return mixed
  1559. * @throws \yii\db\Exception
  1560. * @throws \yii\web\HttpException
  1561. */
  1562. public function actionTraceUpYjExport() {
  1563. $periodNum = Yii::$app->request->get('periodNum');
  1564. if (!$periodNum) return static::notice([]);
  1565. $period = Period::instance();
  1566. $yearMonth = $period->getYearMonth($periodNum);
  1567. $filter = $this->filterCondition([
  1568. 'userName' => 'UI.USER_NAME',
  1569. 'periodNum' => 'CYJ.PERIOD_NUM',
  1570. ]);
  1571. $form = new BonusExportForm();
  1572. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1573. if (!$result) {
  1574. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1575. }
  1576. return static::notice('导出开始,请到文件管理-导出文件查看');
  1577. }
  1578. /**
  1579. * 共享奖向上追溯
  1580. * @return mixed
  1581. * @throws \yii\base\Exception
  1582. * @throws \yii\db\Exception
  1583. * @throws \yii\web\HttpException
  1584. */
  1585. public function actionTraceUpGx() {
  1586. $periodNum = Yii::$app->request->get('periodNum');
  1587. if (!$periodNum) return static::notice([]);
  1588. $period = Period::instance();
  1589. $yearMonth = $period->getYearMonth($periodNum);
  1590. $filter = $this->filterCondition([
  1591. 'userName' => 'UI.USER_NAME',
  1592. 'periodNum' => 'CGX.PERIOD_NUM',
  1593. ]);
  1594. $condition = $filter['condition'];
  1595. $params = $filter['params'];
  1596. $listObj = new TraceUpGxList();
  1597. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1598. return static::notice($data);
  1599. }
  1600. /**
  1601. * 共享奖向上追溯导出
  1602. * @return mixed
  1603. * @throws \yii\db\Exception
  1604. * @throws \yii\web\HttpException
  1605. */
  1606. public function actionTraceUpGxExport() {
  1607. $periodNum = Yii::$app->request->get('periodNum');
  1608. if (!$periodNum) return static::notice([]);
  1609. $period = Period::instance();
  1610. $yearMonth = $period->getYearMonth($periodNum);
  1611. $filter = $this->filterCondition([
  1612. 'userName' => 'UI.USER_NAME',
  1613. 'periodNum' => 'CGX.PERIOD_NUM',
  1614. ]);
  1615. $form = new BonusExportForm();
  1616. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1617. if (!$result) {
  1618. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1619. }
  1620. return static::notice('导出开始,请到文件管理-导出文件查看');
  1621. }
  1622. /**
  1623. * 管理奖向上追溯
  1624. * @return mixed
  1625. * @throws \yii\base\Exception
  1626. * @throws \yii\db\Exception
  1627. * @throws \yii\web\HttpException
  1628. */
  1629. public function actionTraceUpGl() {
  1630. $periodNum = Yii::$app->request->get('periodNum');
  1631. if (!$periodNum) return static::notice([]);
  1632. $period = Period::instance();
  1633. $yearMonth = $period->getYearMonth($periodNum);
  1634. $filter = $this->filterCondition([
  1635. 'userName' => 'UI.USER_NAME',
  1636. 'periodNum' => 'CGL.PERIOD_NUM',
  1637. ]);
  1638. $condition = $filter['condition'];
  1639. $params = $filter['params'];
  1640. $listObj = new TraceUpGlList();
  1641. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1642. return static::notice($data);
  1643. }
  1644. /**
  1645. * 管理奖向上追溯导出
  1646. * @return mixed
  1647. * @throws \yii\db\Exception
  1648. * @throws \yii\web\HttpException
  1649. */
  1650. public function actionTraceUpGlExport() {
  1651. $periodNum = Yii::$app->request->get('periodNum');
  1652. if (!$periodNum) return static::notice([]);
  1653. $period = Period::instance();
  1654. $yearMonth = $period->getYearMonth($periodNum);
  1655. $filter = $this->filterCondition([
  1656. 'userName' => 'UI.USER_NAME',
  1657. 'periodNum' => 'CGL.PERIOD_NUM',
  1658. ]);
  1659. $form = new BonusExportForm();
  1660. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1661. if (!$result) {
  1662. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1663. }
  1664. return static::notice('导出开始,请到文件管理-导出文件查看');
  1665. }
  1666. /**
  1667. * 复销奖向下追溯
  1668. * @return mixed
  1669. * @throws \yii\base\Exception
  1670. * @throws \yii\db\Exception
  1671. * @throws \yii\web\HttpException
  1672. */
  1673. public function actionTraceDownFx() {
  1674. $periodNum = Yii::$app->request->get('periodNum');
  1675. if (!$periodNum) return static::notice([]);
  1676. $period = Period::instance();
  1677. $yearMonth = $period->getYearMonth($periodNum);
  1678. $filter = $this->filterCondition([
  1679. 'userName' => 'UI.USER_NAME',
  1680. 'periodNum' => 'CBF.PERIOD_NUM',
  1681. ]);
  1682. $condition = $filter['condition'];
  1683. $params = $filter['params'];
  1684. $listObj = new TraceDownFxList();
  1685. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1686. return static::notice($data);
  1687. }
  1688. /**
  1689. * 复销奖向下追溯导出
  1690. * @return mixed
  1691. * @throws \yii\db\Exception
  1692. * @throws \yii\web\HttpException
  1693. */
  1694. public function actionTraceDownFxExport() {
  1695. $periodNum = Yii::$app->request->get('periodNum');
  1696. if (!$periodNum) return static::notice([]);
  1697. $period = Period::instance();
  1698. $yearMonth = $period->getYearMonth($periodNum);
  1699. $filter = $this->filterCondition([
  1700. 'userName' => 'UI.USER_NAME',
  1701. 'periodNum' => 'CBF.PERIOD_NUM',
  1702. ]);
  1703. $form = new BonusExportForm();
  1704. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '复销奖向下追溯');
  1705. if (!$result) {
  1706. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1707. }
  1708. return static::notice('导出开始,请到文件管理-导出文件查看');
  1709. }
  1710. /**
  1711. * 复销奖向上追溯
  1712. * @return mixed
  1713. * @throws \yii\base\Exception
  1714. * @throws \yii\db\Exception
  1715. * @throws \yii\web\HttpException
  1716. */
  1717. public function actionTraceUpFx() {
  1718. $periodNum = Yii::$app->request->get('periodNum');
  1719. if (!$periodNum) return static::notice([]);
  1720. $period = Period::instance();
  1721. $yearMonth = $period->getYearMonth($periodNum);
  1722. $filter = $this->filterCondition([
  1723. 'userName' => 'UI.USER_NAME',
  1724. 'periodNum' => 'CBF.PERIOD_NUM',
  1725. ]);
  1726. $condition = $filter['condition'];
  1727. $params = $filter['params'];
  1728. $listObj = new TraceUpFxList();
  1729. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1730. return static::notice($data);
  1731. }
  1732. /**
  1733. * 复销奖向上追溯导出
  1734. * @return mixed
  1735. * @throws \yii\db\Exception
  1736. * @throws \yii\web\HttpException
  1737. */
  1738. public function actionTraceUpFxExport() {
  1739. $periodNum = Yii::$app->request->get('periodNum');
  1740. if (!$periodNum) return static::notice([]);
  1741. $period = Period::instance();
  1742. $yearMonth = $period->getYearMonth($periodNum);
  1743. $filter = $this->filterCondition([
  1744. 'userName' => 'UI.USER_NAME',
  1745. 'periodNum' => 'CBF.PERIOD_NUM',
  1746. ]);
  1747. $form = new BonusExportForm();
  1748. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '复销奖向上追溯');
  1749. if (!$result) {
  1750. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1751. }
  1752. return static::notice('导出开始,请到文件管理-导出文件查看');
  1753. }
  1754. /**
  1755. * 核算会员区域津贴
  1756. * @return mixed
  1757. * @throws \yii\db\Exception
  1758. * @throws \yii\web\HttpException
  1759. */
  1760. public function actionCalcQy() {
  1761. $periodNum = Yii::$app->request->get('periodNum');
  1762. $userName = Yii::$app->request->get('userName');
  1763. $period = Period::instance();
  1764. $yearMonth = $period->getYearMonth($periodNum);
  1765. if (!$userId = Info::getUserIdByUserName($userName)) {
  1766. return static::notice('会员不存在', 400);
  1767. }
  1768. $data = CalcBonus::findUseSlaves()->yearMonth($yearMonth)->where('PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID', [':PERIOD_NUM' => $periodNum, ':USER_ID' => $userId])->asArray()->one();
  1769. if ($data) {
  1770. $data['REAL_NAME'] = Info::getUserRealNameByUserId($userId);
  1771. $data['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$data['LAST_DEC_LV']]['LEVEL_NAME']??'';
  1772. $data['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$data['LAST_EMP_LV']]['LEVEL_NAME']??'';
  1773. $data['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$data['LAST_STATUS']]['label']??'';
  1774. $data['AUDIT_STATUS'] = false;
  1775. 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()) {
  1776. $data['AUDIT_STATUS'] = $resendQy['AUDIT_STATUS'];
  1777. }
  1778. }
  1779. return static::notice($data);
  1780. }
  1781. /**
  1782. * 补发区域津贴列表
  1783. * @return mixed
  1784. * @throws \yii\base\Exception
  1785. * @throws \yii\web\HttpException
  1786. */
  1787. public function actionResendQyList() {
  1788. $filter = $this->filterCondition([
  1789. 'userIds' => 'USER_ID',
  1790. 'filterStatus' => 'RESEND_STATUS',
  1791. 'PERIOD_NUM' => 'PERIOD_NUM',
  1792. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  1793. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  1794. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  1795. 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
  1796. 'LAST_AREA_NAME' => [
  1797. 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1798. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1799. ],
  1800. 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
  1801. 'BONUS_QY' => 'BONUS_QY',
  1802. 'SHOULD_QY' => 'SHOULD_QY',
  1803. 'QY_1L' => 'QY_1L',
  1804. 'SURPLUS_1L' => 'SURPLUS_1L',
  1805. 'QY_2L' => 'QY_2L',
  1806. 'SURPLUS_2L' => 'SURPLUS_2L',
  1807. 'QY_3L' => 'QY_3L',
  1808. 'SURPLUS_3L' => 'SURPLUS_3L',
  1809. 'QY_4L' => 'QY_4L',
  1810. 'SURPLUS_4L' => 'SURPLUS_4L',
  1811. 'QY_5L' => 'QY_5L',
  1812. 'SURPLUS_5L' => 'SURPLUS_5L',
  1813. 'SURPLUS_LS' => 'SURPLUS_LS',
  1814. 'QY_LS' => 'QY_LS',
  1815. ]);
  1816. $condition = $filter['condition'];
  1817. $params = $filter['params'];
  1818. $listObj = new ResendQyList();
  1819. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1820. return static::notice($data);
  1821. }
  1822. /**
  1823. * 区域津贴补发列表导出
  1824. * @return mixed
  1825. * @throws \yii\db\Exception
  1826. * @throws \yii\web\HttpException
  1827. */
  1828. public function actionResendQyListExport() {
  1829. $filter = $this->filterCondition([
  1830. 'userIds' => 'USER_ID',
  1831. 'filterStatus' => 'RESEND_STATUS',
  1832. 'PERIOD_NUM' => 'PERIOD_NUM',
  1833. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  1834. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  1835. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  1836. 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
  1837. 'LAST_AREA_NAME' => [
  1838. 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1839. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1840. ],
  1841. 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
  1842. 'BONUS_QY' => 'BONUS_QY',
  1843. 'SHOULD_QY' => 'SHOULD_QY',
  1844. 'QY_1L' => 'QY_1L',
  1845. 'SURPLUS_1L' => 'SURPLUS_1L',
  1846. 'QY_2L' => 'QY_2L',
  1847. 'SURPLUS_2L' => 'SURPLUS_2L',
  1848. 'QY_3L' => 'QY_3L',
  1849. 'SURPLUS_3L' => 'SURPLUS_3L',
  1850. 'QY_4L' => 'QY_4L',
  1851. 'SURPLUS_4L' => 'SURPLUS_4L',
  1852. 'QY_5L' => 'QY_5L',
  1853. 'SURPLUS_5L' => 'SURPLUS_5L',
  1854. 'SURPLUS_LS' => 'SURPLUS_LS',
  1855. 'QY_LS' => 'QY_LS',
  1856. ]);
  1857. $form = new BonusExportForm();
  1858. $result = $form->run($filter, '区域津贴补发列表');
  1859. if (!$result) {
  1860. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1861. }
  1862. return static::notice('导出开始,请到文件管理-导出文件查看');
  1863. }
  1864. /**
  1865. * 补发区域津贴
  1866. * @return mixed
  1867. * @throws \yii\db\Exception
  1868. * @throws \yii\web\HttpException
  1869. */
  1870. public function actionResendQy() {
  1871. if (Yii::$app->request->isPost) {
  1872. $formModel = new ResendQYForm();
  1873. $formModel->scenario = 'apply';
  1874. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->apply()) {
  1875. if($result['logs']){
  1876. /*foreach ($result['logs'] as $k => $value) {
  1877. $userName = Info::getUserNameByUserId($value);
  1878. // Log::adminHandle('申请为会员' . $userName . '发放补发区域津贴', 0, $value, $userName);
  1879. }*/
  1880. return static::notice('申请成功,请在补发区域津贴审核管理中审核');
  1881. }else{
  1882. return static::notice('没有符合补发条件的记录',400);
  1883. }
  1884. } else {
  1885. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1886. }
  1887. }
  1888. return static::notice('非法请求', 400);
  1889. }
  1890. /**
  1891. * 补发审核表
  1892. * @return mixed
  1893. * @throws \yii\base\Exception
  1894. * @throws \yii\web\HttpException
  1895. */
  1896. public function actionResendQyAuditList() {
  1897. $filter = $this->filterCondition([
  1898. 'userIds' => 'RQYA.USER_ID',
  1899. 'filterStatus' => 'RQYA.AUDIT_STATUS',
  1900. 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
  1901. 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
  1902. 'CREATED_AT' => 'RQYA.CREATED_AT',
  1903. 'AUDITED_AT' => 'RQYA.AUDITED_AT',
  1904. 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
  1905. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  1906. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1907. ]);
  1908. $condition = $filter['condition'];
  1909. $params = $filter['params'];
  1910. $listObj = new ResendQyAuditList();
  1911. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1912. return static::notice($data);
  1913. }
  1914. /**
  1915. * 补发审核表导出
  1916. * @return mixed
  1917. * @throws \yii\db\Exception
  1918. * @throws \yii\web\HttpException
  1919. */
  1920. public function actionResendQyAuditListExport() {
  1921. $filter = $this->filterCondition([
  1922. 'userIds' => 'RQYA.USER_ID',
  1923. 'filterStatus' => 'RQYA.AUDIT_STATUS',
  1924. 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
  1925. 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
  1926. 'CREATED_AT' => 'RQYA.CREATED_AT',
  1927. 'AUDITED_AT' => 'RQYA.AUDITED_AT',
  1928. 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
  1929. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  1930. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1931. ]);
  1932. $form = new BonusExportForm();
  1933. $result = $form->run($filter, '补发区域津贴审核列表');
  1934. if (!$result) {
  1935. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1936. }
  1937. return static::notice('导出开始,请到文件管理-导出文件查看');
  1938. }
  1939. /**
  1940. * 审核补发区域津贴
  1941. * @return mixed
  1942. * @throws \yii\db\Exception
  1943. * @throws \yii\web\HttpException
  1944. */
  1945. public function actionResendQyAudit() {
  1946. $formModel = new ResendQYForm();
  1947. $formModel->scenario = 'audit';
  1948. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1949. /*foreach ($result['logs'] as $k => $value) {
  1950. $userName = Info::getUserNameByUserId($value);
  1951. // Log::adminHandle('审核为会员' . $userName . '补发区域津贴', 1, $value, $userName);
  1952. }*/
  1953. return static::notice('审核补发区域津贴成功');
  1954. }
  1955. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1956. }
  1957. /**
  1958. * 删除补发区域津贴审核信息
  1959. * @return mixed
  1960. * @throws \yii\db\Exception
  1961. * @throws \yii\web\HttpException
  1962. */
  1963. public function actionResendQyAuditDelete() {
  1964. $resendQYForm = new ResendQYForm();
  1965. $result = static::delete(ResendQYAudit::class, function ($selected) use ($resendQYForm) {
  1966. $resendQYForm->beforeDelete($selected);
  1967. // Log::adminHandle('删除审核会员余额信息');
  1968. }, function ($selected) use ($resendQYForm) {
  1969. $resendQYForm->delete($selected);
  1970. // Log::adminHandle('删除审核会员余额信息');
  1971. }, true);
  1972. return $result;
  1973. }
  1974. /**
  1975. * 余额列表
  1976. * @return mixed
  1977. * @throws \yii\base\Exception
  1978. * @throws \yii\web\HttpException
  1979. */
  1980. public function actionBalanceList() {
  1981. $filter = $this->filterCondition([
  1982. 'USER_NAME' => 'UI.USER_NAME',
  1983. 'REAL_NAME' => 'UI.REAL_NAME',
  1984. 'userIds' => 'UB.USER_ID',
  1985. 'BONUS' => 'BONUS',
  1986. 'RECONSUME_POINTS' => 'RECONSUME_POINTS',
  1987. 'CASH' => 'CASH',
  1988. 'IS_DEC' => 'UI.IS_DEC',
  1989. 'PERIOD_AT' => 'UI.PERIOD_AT',
  1990. 'MOBILE' => 'UI.MOBILE',
  1991. 'TEL' => 'UI.TEL',
  1992. // 'CF' => 'CF',
  1993. // 'LX' => 'LX',
  1994. // 'HIGHEST_EMP_LV_NAME' => 'UI.HIGHEST_EMP_LV',
  1995. // 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1996. ]);
  1997. $condition = $filter['condition'];
  1998. $params = $filter['params'];
  1999. $listObj = new BalanceList();
  2000. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2001. return static::notice($data);
  2002. }
  2003. /**
  2004. * 会员奖金余额导出
  2005. * @return mixed
  2006. * @throws \yii\db\Exception
  2007. * @throws \yii\web\HttpException
  2008. */
  2009. public function actionBalanceExport() {
  2010. $filter = $this->filterCondition([
  2011. 'USER_NAME' => 'UI.USER_NAME',
  2012. 'REAL_NAME' => 'UI.REAL_NAME',
  2013. 'userIds' => 'UB.USER_ID',
  2014. 'BONUS' => 'BONUS',
  2015. 'IS_DEC' => 'UI.IS_DEC',
  2016. 'PERIOD_AT' => 'UI.PERIOD_AT',
  2017. 'MOBILE' => 'UI.MOBILE',
  2018. 'TEL' => 'UI.TEL',
  2019. // 'CF' => 'CF',
  2020. // 'LX' => 'LX',
  2021. ]);
  2022. $form = new BonusExportForm();
  2023. $result = $form->run($filter, '会员奖金余额');
  2024. if (!$result) {
  2025. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2026. }
  2027. return static::notice('导出开始,请到文件管理-导出文件查看');
  2028. }
  2029. /**
  2030. * 报单中心店补/补贴追溯
  2031. * @return mixed
  2032. * @throws \yii\base\Exception
  2033. * @throws \yii\web\HttpException
  2034. */
  2035. public function actionTraceBt() {
  2036. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2037. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2038. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2039. $filterStatus = Yii::$app->request->get('filterStatus');
  2040. $filter = $this->filterCondition([
  2041. 'userName' => 'UI.USER_NAME',
  2042. ]);
  2043. $condition = $filter['condition'];
  2044. $params = $filter['params'];
  2045. if ($startPeriodNum) {
  2046. $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
  2047. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2048. }
  2049. if ($endPeriodNum) {
  2050. $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
  2051. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2052. }
  2053. if ($filterStatus) {
  2054. $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
  2055. $params[':BT_TYPE'] = $filterStatus;
  2056. }
  2057. $listObj = new TraceBtList();
  2058. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2059. return static::notice($data);
  2060. }
  2061. /**
  2062. * 报单中心补贴追溯导出
  2063. * @return mixed
  2064. * @throws \yii\db\Exception
  2065. * @throws \yii\web\HttpException
  2066. */
  2067. public function actionTraceBtExport() {
  2068. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2069. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2070. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2071. $filterStatus = Yii::$app->request->get('filterStatus');
  2072. $filter = $this->filterCondition([
  2073. 'userName' => 'UI.USER_NAME',
  2074. ]);
  2075. $condition = $filter['condition'];
  2076. $params = $filter['params'];
  2077. if ($startPeriodNum) {
  2078. $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
  2079. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2080. }
  2081. if ($endPeriodNum) {
  2082. $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
  2083. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2084. }
  2085. if ($filterStatus) {
  2086. $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
  2087. $params[':BT_TYPE'] = $filterStatus;
  2088. }
  2089. $form = new BonusExportForm();
  2090. $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心补贴追溯');
  2091. if (!$result) {
  2092. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2093. }
  2094. return static::notice('导出开始,请到文件管理-导出文件查看');
  2095. }
  2096. /**
  2097. * 报单中心货补追溯
  2098. * @return mixed
  2099. * @throws \yii\base\Exception
  2100. * @throws \yii\web\HttpException
  2101. */
  2102. public function actionTraceFl() {
  2103. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2104. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2105. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2106. $filter = $this->filterCondition([
  2107. 'userName' => 'UI.USER_NAME',
  2108. ]);
  2109. $condition = $filter['condition'];
  2110. $params = $filter['params'];
  2111. if ($startPeriodNum) {
  2112. $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
  2113. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2114. }
  2115. if ($endPeriodNum) {
  2116. $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
  2117. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2118. }
  2119. $listObj = new TraceFlList();
  2120. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2121. return static::notice($data);
  2122. }
  2123. /**
  2124. * 报单中心货补追溯导出
  2125. * @return mixed
  2126. * @throws \yii\db\Exception
  2127. * @throws \yii\web\HttpException
  2128. */
  2129. public function actionTraceFlExport() {
  2130. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2131. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2132. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2133. $filter = $this->filterCondition([
  2134. 'userName' => 'UI.USER_NAME',
  2135. ]);
  2136. $condition = $filter['condition'];
  2137. $params = $filter['params'];
  2138. if ($startPeriodNum) {
  2139. $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
  2140. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2141. }
  2142. if ($endPeriodNum) {
  2143. $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
  2144. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2145. }
  2146. $form = new BonusExportForm();
  2147. $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心货补追溯');
  2148. if (!$result) {
  2149. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2150. }
  2151. return static::notice('导出开始,请到文件管理-导出文件查看');
  2152. }
  2153. /**
  2154. * 区域业绩提成追溯
  2155. * @return mixed
  2156. * @throws \yii\base\Exception
  2157. * @throws \yii\web\HttpException
  2158. */
  2159. public function actionTraceFw() {
  2160. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2161. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2162. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2163. $filter = $this->filterCondition([
  2164. 'userName' => 'UI.USER_NAME',
  2165. ]);
  2166. $condition = $filter['condition'];
  2167. $params = $filter['params'];
  2168. if ($startPeriodNum) {
  2169. $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
  2170. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2171. }
  2172. if ($endPeriodNum) {
  2173. $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
  2174. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2175. }
  2176. $listObj = new TraceFwList();
  2177. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2178. return static::notice($data);
  2179. }
  2180. /**
  2181. * 区域业绩提成导出
  2182. * @return mixed
  2183. * @throws \yii\db\Exception
  2184. * @throws \yii\web\HttpException
  2185. */
  2186. public function actionTraceFwExport() {
  2187. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2188. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2189. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2190. $filter = $this->filterCondition([
  2191. 'userName' => 'UI.USER_NAME',
  2192. ]);
  2193. $condition = $filter['condition'];
  2194. $params = $filter['params'];
  2195. if ($startPeriodNum) {
  2196. $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
  2197. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2198. }
  2199. if ($endPeriodNum) {
  2200. $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
  2201. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2202. }
  2203. $form = new BonusExportForm();
  2204. $result = $form->run(['condition'=>$condition, 'params'=>$params], '区域业绩提成追溯');
  2205. if (!$result) {
  2206. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2207. }
  2208. return static::notice('导出开始,请到文件管理-导出文件查看');
  2209. }
  2210. /**
  2211. * 业绩单
  2212. * @return mixed
  2213. * @throws \yii\base\Exception
  2214. * @throws \yii\web\HttpException
  2215. */
  2216. public function actionPerfOrder(){
  2217. $filter = $this->filterCondition([
  2218. 'PERIOD_NUM' => 'PO.PERIOD_NUM',
  2219. 'SN' => 'PO.SN',
  2220. 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
  2221. 'USER_NAME' => 'U.USER_NAME',
  2222. 'REAL_NAME' => 'U.REAL_NAME',
  2223. 'userIds' => 'PO.USER_ID',
  2224. 'filterType' => 'PO.DEC_TYPE',
  2225. 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
  2226. 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
  2227. 'PV' => 'PO.PV',
  2228. 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
  2229. 'DEC_SN' => 'PO.DEC_SN',
  2230. 'CREATED_AT' => 'PO.CREATED_AT',
  2231. ]);
  2232. $condition = $filter['condition'];
  2233. $params = $filter['params'];
  2234. $listObj = new PerfOrderList();
  2235. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2236. return static::notice($data);
  2237. }
  2238. /**
  2239. * 业绩单导出
  2240. * @return mixed
  2241. * @throws \yii\db\Exception
  2242. * @throws \yii\web\HttpException
  2243. */
  2244. public function actionPerfOrderExport() {
  2245. $filter = $this->filterCondition([
  2246. 'PERIOD_NUM' => 'PO.PERIOD_NUM',
  2247. 'SN' => 'PO.SN',
  2248. 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
  2249. 'userIds' => 'PO.USER_ID',
  2250. 'filterType' => 'PO.DEC_TYPE',
  2251. 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
  2252. 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
  2253. 'PV' => 'PO.PV',
  2254. 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
  2255. 'DEC_SN' => 'PO.DEC_SN',
  2256. 'LAST_SUB_COM_NAME' => 'PO.LAST_SUB_COM_ID',
  2257. 'LAST_SYSTEM_NAME' => 'PO.LAST_SYSTEM_ID',
  2258. 'LAST_AREA' => [
  2259. 'FIELD' => ['PO.LAST_PROVINCE', 'PO.LAST_CITY', 'PO.LAST_COUNTY'],
  2260. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  2261. ],
  2262. 'DEC_USER_NAME' => 'DUI.USER_NAME',
  2263. 'LAST_DEC_DEC_LV_NAME' => 'PO.LAST_DEC_DEC_LV',
  2264. 'LAST_DEC_SUB_COM_NAME' => 'PO.LAST_DEC_SUB_COM_ID',
  2265. 'LAST_DEC_AREA' => [
  2266. 'FIELD' => ['PO.LAST_DEC_PROVINCE', 'PO.LAST_DEC_CITY', 'PO.LAST_DEC_COUNTY'],
  2267. 'BIND' => ['LAST_DEC_PROVINCE', 'LAST_DEC_CITY', 'LAST_DEC_COUNTY'],
  2268. ],
  2269. 'CREATED_AT' => 'PO.CREATED_AT',
  2270. 'CLOSED_AT' => 'PO.CLOSED_AT',
  2271. ]);
  2272. $condition = $filter['condition'];
  2273. $params = $filter['params'];
  2274. $form = new BonusExportForm();
  2275. $result = $form->run(['condition'=>$condition, 'params'=>$params], '业绩单');
  2276. if (!$result) {
  2277. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2278. }
  2279. return static::notice('导出开始,请到文件管理-导出文件查看');
  2280. }
  2281. /**
  2282. * 月积分
  2283. * @return mixed
  2284. * @throws \yii\base\Exception
  2285. * @throws \yii\web\HttpException
  2286. */
  2287. public function actionScoreMonth(){
  2288. $filter = $this->filterCondition([
  2289. 'USER_NAME' => 'U.USER_NAME',
  2290. 'userIds' => 'SM.USER_ID',
  2291. 'CALC_MONTH' => 'SM.CALC_MONTH',
  2292. 'CREATED_AT' => 'SM.CREATED_AT',
  2293. ]);
  2294. $condition = $filter['condition'];
  2295. $params = $filter['params'];
  2296. $listObj = new ScoreMonthList();
  2297. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2298. return static::notice($data);
  2299. }
  2300. /**
  2301. * 月积分导出
  2302. * @return mixed
  2303. * @throws \yii\db\Exception
  2304. * @throws \yii\web\HttpException
  2305. */
  2306. public function actionScoreMonthExport() {
  2307. $filter = $this->filterCondition([
  2308. 'USER_NAME' => 'U.USER_NAME',
  2309. 'userIds' => 'SM.USER_ID',
  2310. 'CALC_MONTH' => 'SM.CALC_MONTH',
  2311. 'CREATED_AT' => 'SM.CREATED_AT',
  2312. ]);
  2313. $condition = $filter['condition'];
  2314. $params = $filter['params'];
  2315. $form = new BonusExportForm();
  2316. $result = $form->run(['condition'=>$condition, 'params'=>$params], '月积分');
  2317. if (!$result) {
  2318. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2319. }
  2320. return static::notice('导出开始,请到文件管理-导出文件查看');
  2321. }
  2322. /**
  2323. * 月业绩
  2324. * @return mixed
  2325. * @throws \yii\base\Exception
  2326. * @throws \yii\web\HttpException
  2327. */
  2328. public function actionPerfMonth(){
  2329. $filter = $this->filterCondition([
  2330. 'USER_NAME' => 'U.USER_NAME',
  2331. 'REC_USER_NAME' => 'RU.USER_NAME',
  2332. 'userIds' => 'PM.USER_ID',
  2333. 'CALC_MONTH' => 'PM.CALC_MONTH',
  2334. 'CREATED_AT' => 'PM.CREATED_AT',
  2335. ]);
  2336. $condition = $filter['condition'];
  2337. $params = $filter['params'];
  2338. $listObj = new PerfMonthList();
  2339. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2340. return static::notice($data);
  2341. }
  2342. /**
  2343. * 月业绩导出
  2344. * @return mixed
  2345. * @throws \yii\db\Exception
  2346. * @throws \yii\web\HttpException
  2347. */
  2348. public function actionPerfMonthExport() {
  2349. $filter = $this->filterCondition([
  2350. 'USER_NAME' => 'U.USER_NAME',
  2351. 'REC_USER_NAME' => 'RU.USER_NAME',
  2352. 'userIds' => 'PM.USER_ID',
  2353. 'CALC_MONTH' => 'PM.CALC_MONTH',
  2354. 'CREATED_AT' => 'PM.CREATED_AT',
  2355. ]);
  2356. $condition = $filter['condition'];
  2357. $params = $filter['params'];
  2358. $form = new BonusExportForm();
  2359. $result = $form->run(['condition'=>$condition, 'params'=>$params], '月业绩');
  2360. if (!$result) {
  2361. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2362. }
  2363. return static::notice('导出开始,请到文件管理-导出文件查看');
  2364. }
  2365. /**
  2366. * 期业绩
  2367. * @return mixed
  2368. * @throws \yii\base\Exception
  2369. * @throws \yii\web\HttpException
  2370. */
  2371. public function actionPerfPeriodList(){
  2372. $filter = $this->filterCondition([
  2373. 'USER_NAME' => 'U.USER_NAME',
  2374. 'userIds' => 'PP.USER_ID',
  2375. 'PERIOD_NUM' => 'PP.PERIOD_NUM',
  2376. 'CREATED_AT' => 'PP.CREATED_AT',
  2377. ]);
  2378. $condition = $filter['condition'];
  2379. $params = $filter['params'];
  2380. $listObj = new PerfPeriodList();
  2381. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2382. return static::notice($data);
  2383. }
  2384. /**
  2385. * 期业绩导出
  2386. * @return mixed
  2387. * @throws \yii\db\Exception
  2388. * @throws \yii\web\HttpException
  2389. */
  2390. public function actionPerfPeriodListExport() {
  2391. $filter = $this->filterCondition([
  2392. 'USER_NAME' => 'U.USER_NAME',
  2393. 'userIds' => 'PP.USER_ID',
  2394. 'PERIOD_NUM' => 'PP.PERIOD_NUM',
  2395. 'CREATED_AT' => 'PP.CREATED_AT',
  2396. ]);
  2397. $condition = $filter['condition'];
  2398. $params = $filter['params'];
  2399. $form = new BonusExportForm();
  2400. $result = $form->run(['condition'=>$condition, 'params'=>$params], '期业绩');
  2401. if (!$result) {
  2402. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2403. }
  2404. return static::notice('导出开始,请到文件管理-导出文件查看');
  2405. }
  2406. /**
  2407. * 达标业绩
  2408. * @return mixed
  2409. * @throws \yii\base\Exception
  2410. * @throws \yii\web\HttpException
  2411. */
  2412. public function actionPerfStandard(){
  2413. $filter = $this->filterCondition([
  2414. 'USER_NAME' => 'U.USER_NAME',
  2415. 'REC_USER_NAME' => 'RU.USER_NAME',
  2416. 'userIds' => 'PS.USER_ID',
  2417. 'CALC_MONTH' => 'PS.CALC_MONTH',
  2418. 'CREATED_AT' => 'PS.CREATED_AT',
  2419. ]);
  2420. $condition = $filter['condition'];
  2421. $params = $filter['params'];
  2422. $listObj = new PerfStandardList();
  2423. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2424. return static::notice($data);
  2425. }
  2426. /**
  2427. * 达标业绩导出
  2428. * @return mixed
  2429. * @throws \yii\db\Exception
  2430. * @throws \yii\web\HttpException
  2431. */
  2432. public function actionPerfStandardExport() {
  2433. $filter = $this->filterCondition([
  2434. 'USER_NAME' => 'U.USER_NAME',
  2435. 'REC_USER_NAME' => 'RU.USER_NAME',
  2436. 'userIds' => 'PS.USER_ID',
  2437. 'CALC_MONTH' => 'PS.CALC_MONTH',
  2438. 'CREATED_AT' => 'PS.CREATED_AT',
  2439. ]);
  2440. $condition = $filter['condition'];
  2441. $params = $filter['params'];
  2442. $form = new BonusExportForm();
  2443. $result = $form->run(['condition'=>$condition, 'params'=>$params], '达标业绩');
  2444. if (!$result) {
  2445. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2446. }
  2447. return static::notice('导出开始,请到文件管理-导出文件查看');
  2448. }
  2449. /**
  2450. * 会员实时业绩
  2451. * @return mixed
  2452. * @throws \yii\web\HttpException
  2453. */
  2454. public function actionRealTimePerf() {
  2455. $userName = Yii::$app->request->get('userName');
  2456. if (!$userId = Info::getUserIdByUserName($userName)) {
  2457. return static::notice('会员不存在', 400);
  2458. }
  2459. $period = Period::instance();
  2460. $newPerf = Perf::getPeriodNewPerf($userId);
  2461. $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'])]];
  2462. $monthPerf = Perf::getMonthPerf($userId);
  2463. $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'])]];
  2464. $lastMonth = PerfMonth::getMonthPerf($period->getLastMonth()['yearMonth'], $userId);
  2465. $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'])]];
  2466. //是否合格
  2467. // $lastChkStatus = '';
  2468. // $lastMonthPerfChk = Cache::getSystemConfig()['lastMonthPerfChk']['VALUE'];
  2469. // $lastArr = [$lastMonth['PV_1L_TOTAL'], $lastMonth['PV_2L_TOTAL'], $lastMonth['PV_3L_TOTAL'], $lastMonth['PV_4L_TOTAL'], $lastMonth['PV_5L_TOTAL']];
  2470. // if (array_sum($lastArr) >= $lastMonthPerfChk) {
  2471. // $lastChkStatus = '已合格';
  2472. // }
  2473. //判断大区
  2474. // $bigLocation = array_search(max($lastArr), $lastArr) + 1;
  2475. return static::notice(['weekData' => $weekData, 'monthData' => $monthData, 'lastData' => $lastData]);
  2476. }
  2477. /**
  2478. * 荣衔业绩
  2479. * @return mixed
  2480. * @throws \yii\web\HttpException
  2481. */
  2482. public function actionYcPerf() {
  2483. $userName = Yii::$app->request->get('userName');
  2484. if (!$userId = Info::getUserIdByUserName($userName)) {
  2485. return static::notice('会员不存在', 400);
  2486. }
  2487. $userPerfData = Perf::getUserPerf($userId);
  2488. $ycPerfList = [];
  2489. //查找推荐的子会员
  2490. $childrenList = UserInfo::findUseDbCalc()->select('USER_ID')->where('REC_UID=:REC_UID', [
  2491. 'REC_UID' => $userId
  2492. ])->asArray()->all();
  2493. $maxPvPss = 0;
  2494. $childSumPerf = 0;
  2495. foreach ($childrenList as $child) {
  2496. $childBaseUser = Info::getBaseUserById($child['USER_ID']);
  2497. if( !$childBaseUser ) continue;
  2498. $childPerfData = Perf::getUserPerf($child['USER_ID']);
  2499. if( !$childPerfData ) continue;
  2500. $childPvPcs = $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'];
  2501. $childPvPssTotal = $childPvPcs + $childPerfData['PV_PSS'];
  2502. $childSumPerf += $childPvPssTotal;
  2503. if( $childPvPssTotal >= $maxPvPss ) {
  2504. $maxPvPss = $childPvPssTotal;
  2505. }
  2506. $ycPerfList[] = [
  2507. 'USER_NAME'=>$childBaseUser['USER_NAME'],
  2508. 'REAL_NAME'=>$childBaseUser['REAL_NAME'],
  2509. 'PV_PCS' => $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'],
  2510. 'PV_PSS_TOTAL' => $childPerfData['PV_PSS_TOTAL'],
  2511. 'MAX_DEPART_PERF' => '-',
  2512. 'OTHER_DEPART_PERF' => '-',
  2513. 'PV_PSS_SUM_TOTAL' => round($childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'] + $childPerfData['PV_PSS_TOTAL'],2),
  2514. ];
  2515. }
  2516. if( $userPerfData ) {
  2517. $baseUser = Info::getBaseUserById($userId);
  2518. $ycPerfData = [
  2519. 'USER_NAME'=>$baseUser['USER_NAME'],
  2520. 'REAL_NAME'=>$baseUser['REAL_NAME'],
  2521. 'PV_PCS' => $userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'],
  2522. 'PV_PSS_TOTAL' => $userPerfData['PV_PSS_TOTAL'],
  2523. 'MAX_DEPART_PERF' => round($maxPvPss, 2),
  2524. 'OTHER_DEPART_PERF' => round($childSumPerf-$maxPvPss, 2),
  2525. 'PV_PSS_SUM_TOTAL' => round($userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'] + $userPerfData['PV_PSS_TOTAL'],2),
  2526. ];
  2527. array_unshift($ycPerfList, $ycPerfData);
  2528. }
  2529. return static::notice(['ycPerfList' => $ycPerfList]);
  2530. }
  2531. /**
  2532. * 用户业绩
  2533. * @return mixed
  2534. * @throws \yii\web\HttpException
  2535. */
  2536. public function actionUserPerf() {
  2537. $filter = $this->filterCondition([
  2538. 'USER_NAME' => 'U.USER_NAME',
  2539. ]);
  2540. $condition = $filter['condition'];
  2541. $params = $filter['params'];
  2542. $listObj = new UserPerfList();
  2543. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2544. return static::notice($data);
  2545. }
  2546. /**
  2547. * 月业绩导出
  2548. * @return mixed
  2549. * @throws \yii\db\Exception
  2550. * @throws \yii\web\HttpException
  2551. */
  2552. public function actionUserPerfExport() {
  2553. $filter = $this->filterCondition([
  2554. 'USER_NAME' => 'U.USER_NAME',
  2555. ]);
  2556. $condition = $filter['condition'];
  2557. $params = $filter['params'];
  2558. $form = new BonusExportForm();
  2559. $result = $form->run(['condition'=>$condition, 'params'=>$params], '用户业绩');
  2560. if (!$result) {
  2561. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2562. }
  2563. return static::notice('导出开始,请到文件管理-导出文件查看');
  2564. }
  2565. }