BonusController.php 108 KB

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