BonusController.php 105 KB

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