BonusController.php 103 KB

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