BonusController.php 103 KB

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