BonusController.php 104 KB

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