BonusController.php 107 KB

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