BonusController.php 103 KB

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