BonusController.php 103 KB

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