BonusController.php 99 KB

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