BonusController.php 103 KB

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