BonusController.php 103 KB

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