BonusController.php 100 KB

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