BonusController.php 103 KB

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