TraceUpQyList.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\bonus\CalcCache;
  5. use common\helpers\Cache;
  6. use common\helpers\Tool;
  7. use common\helpers\user\Info;
  8. use common\libs\dataList\column\Price;
  9. use common\libs\dataList\column\YesNo;
  10. use common\libs\dataList\DataListInterface;
  11. use common\models\CalcBonus;
  12. use common\models\PerfOrder;
  13. use common\models\PerfPeriod;
  14. use common\models\Period;
  15. use common\models\Region;
  16. use common\models\UserBind;
  17. use common\models\UserBonus;
  18. use common\models\UserInfo;
  19. use common\libs\dataList\column\DateTime;
  20. use common\models\UserNetwork;
  21. use common\models\UserSystem;
  22. use common\models\Withdraw;
  23. use Yii;
  24. class TraceUpQyList extends \common\libs\dataList\DataList implements DataListInterface
  25. {
  26. /**
  27. * 列表名称
  28. * @return string
  29. */
  30. public function getListName(){
  31. return '团队奖向上追溯';
  32. }
  33. /**
  34. * 列表筛选到的数据
  35. * @throws \yii\base\Exception
  36. */
  37. public function dataHandle()
  38. {
  39. $userId = $this->others['userId'];
  40. $periodNum = $this->others['periodNum'];
  41. $data = UserNetwork::getAllParentFromPeriodWithPage($userId, $periodNum);
  42. if (isset($data['list']) && $data['list']) {
  43. $decTotal = CalcCache::nowPeriodPerf($userId, $periodNum);
  44. foreach ($data['list'] as $key => $value) {
  45. $perfPeriod = PerfPeriod::findOneAsArray('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$value['USER_ID'],':PERIOD_NUM'=>$periodNum]);
  46. $data['list'][$key]['PERIOD_NUM'] = $perfPeriod['PERIOD_NUM'];
  47. $data['list'][$key]['DEC_TOTAL'] = $decTotal['PV_PCS_ZC'] + $decTotal['PV_PCS_ZG'] +$decTotal['PV_LS_TOUCH'];
  48. $data['list'][$key]['USER_NAME'] = Info::getUserNameByUserId($value['USER_ID']);
  49. $data['list'][$key]['REAL_NAME'] = Info::getUserRealNameByUserId($value['USER_ID']);
  50. $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$perfPeriod['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
  51. $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$perfPeriod['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
  52. $data['list'][$key]['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$perfPeriod['LAST_STATUS']]['label'] ?? '';
  53. $data['list'][$key]['PV_1L_TOUCH'] = $perfPeriod['PV_1L_TOUCH'];
  54. $data['list'][$key]['PV_2L_TOUCH'] = $perfPeriod['PV_2L_TOUCH'];
  55. $data['list'][$key]['PV_3L_TOUCH'] = $perfPeriod['PV_3L_TOUCH'];
  56. $data['list'][$key]['PV_4L_TOUCH'] = $perfPeriod['PV_4L_TOUCH'];
  57. $data['list'][$key]['PV_5L_TOUCH'] = $perfPeriod['PV_5L_TOUCH'];
  58. $data['list'][$key]['SURPLUS_1L'] = $perfPeriod['SURPLUS_1L'];
  59. $data['list'][$key]['SURPLUS_2L'] = $perfPeriod['SURPLUS_2L'];
  60. $data['list'][$key]['SURPLUS_3L'] = $perfPeriod['SURPLUS_3L'];
  61. $data['list'][$key]['SURPLUS_4L'] = $perfPeriod['SURPLUS_4L'];
  62. $data['list'][$key]['SURPLUS_5L'] = $perfPeriod['SURPLUS_5L'];
  63. $data['list'][$key]['CALC_MONTH'] = $perfPeriod['CALC_MONTH'];
  64. //区域业绩
  65. $pervSurplusPerf = CalcCache::surplusPerf($value['USER_ID'], $periodNum);
  66. $data['list'][$key]['QY_1L'] = $data['list'][$key]['PV_1L_TOUCH'] + $pervSurplusPerf['SURPLUS_1L'];
  67. $data['list'][$key]['QY_2L'] = $data['list'][$key]['PV_2L_TOUCH'] + $pervSurplusPerf['SURPLUS_2L'];
  68. $data['list'][$key]['QY_3L'] = $data['list'][$key]['PV_3L_TOUCH'] + $pervSurplusPerf['SURPLUS_3L'];
  69. $data['list'][$key]['QY_4L'] = $data['list'][$key]['PV_4L_TOUCH'] + $pervSurplusPerf['SURPLUS_4L'];
  70. $data['list'][$key]['QY_5L'] = $data['list'][$key]['PV_5L_TOUCH'] + $pervSurplusPerf['SURPLUS_5L'];
  71. unset($bonus,$bigLocation);
  72. }
  73. } else {
  74. $data['list'] = [];
  75. }
  76. $this->listData = $data;
  77. }
  78. /**
  79. * 要展示和导出的所有字段
  80. * @return array
  81. */
  82. public function getColumn(){
  83. if(!$this->columns){
  84. $this->columns = [
  85. 'PERIOD_NUM' => [
  86. 'header' => '期数',
  87. 'headerOther' => [
  88. 'width' => '150',
  89. ],
  90. ],
  91. 'USER_NAME' => [
  92. 'header' => '上级编号',
  93. 'headerOther' => [
  94. 'width' => '150',
  95. ],
  96. 'valueOther' => [
  97. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  98. ],
  99. ],
  100. 'REAL_NAME' => [
  101. 'header' => '上级姓名',
  102. 'headerOther' => [
  103. 'width' => '120',
  104. ],
  105. 'valueOther' => [
  106. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  107. ],
  108. ],
  109. 'LOCATION' => [
  110. 'header' => '市场',
  111. 'headerOther' => [
  112. 'width' => '100',
  113. ],
  114. ],
  115. 'LAST_STATUS_NAME' => [
  116. 'header' => '结算时状态',
  117. 'headerOther' => [
  118. 'width' => '110',
  119. ],
  120. ],
  121. 'LAST_DEC_LV_NAME' => [
  122. 'header' => '结算时会员级别',
  123. 'headerOther' => [
  124. 'width' => '120',
  125. ],
  126. ],
  127. 'LAST_EMP_LV_NAME' => [
  128. 'header' => '结算时会员聘级',
  129. 'headerOther' => [
  130. 'width' => '140',
  131. ],
  132. ],
  133. 'DEC_TOTAL' => [
  134. 'header' => '报单总积分',
  135. 'headerOther' => [
  136. 'width' => '110',
  137. ],
  138. 'value' => function($row) {
  139. return (new Price([
  140. 'value' => $row['DEC_TOTAL'],
  141. ]))->result();
  142. },
  143. ],
  144. 'PV_1L_TOUCH' => [
  145. 'header' => '一市场新增业绩',
  146. 'headerOther' => [
  147. 'width' => '150',
  148. ],
  149. 'value' => function($row) {
  150. return (new Price([
  151. 'value' => $row['PV_1L_TOUCH'],
  152. ]))->result();
  153. },
  154. 'valueOther' => [
  155. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  156. ]
  157. ],
  158. 'QY_1L' => [
  159. 'header' => '一市场区域业绩',
  160. 'headerOther' => [
  161. 'width' => '150',
  162. ],
  163. 'value' => function($row) {
  164. return (new Price([
  165. 'value' => $row['QY_1L'],
  166. ]))->result();
  167. },
  168. 'valueOther' => [
  169. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  170. ]
  171. ],
  172. 'SURPLUS_1L' => [
  173. 'header' => '一市场结余业绩',
  174. 'headerOther' => [
  175. 'width' => '150',
  176. ],
  177. 'value' => function($row) {
  178. return (new Price([
  179. 'value' => $row['SURPLUS_1L'],
  180. ]))->result();
  181. },
  182. 'valueOther' => [
  183. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  184. ]
  185. ],
  186. 'PV_2L_TOUCH' => [
  187. 'header' => '二市场新增业绩',
  188. 'headerOther' => [
  189. 'width' => '150',
  190. ],
  191. 'value' => function($row) {
  192. return (new Price([
  193. 'value' => $row['PV_2L_TOUCH'],
  194. ]))->result();
  195. },
  196. 'valueOther' => [
  197. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  198. ]
  199. ],
  200. 'QY_2L' => [
  201. 'header' => '二市场区域业绩',
  202. 'headerOther' => [
  203. 'width' => '150',
  204. ],
  205. 'value' => function($row) {
  206. return (new Price([
  207. 'value' => $row['QY_2L'],
  208. ]))->result();
  209. },
  210. 'valueOther' => [
  211. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  212. ]
  213. ],
  214. 'SURPLUS_2L' => [
  215. 'header' => '二市场结余业绩',
  216. 'headerOther' => [
  217. 'width' => '150',
  218. ],
  219. 'value' => function($row) {
  220. return (new Price([
  221. 'value' => $row['SURPLUS_2L'],
  222. ]))->result();
  223. },
  224. 'valueOther' => [
  225. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  226. ]
  227. ],
  228. 'PV_3L_TOUCH' => [
  229. 'header' => '三市场新增业绩',
  230. 'headerOther' => [
  231. 'width' => '150',
  232. ],
  233. 'value' => function($row) {
  234. return (new Price([
  235. 'value' => $row['PV_3L_TOUCH'],
  236. ]))->result();
  237. },
  238. 'valueOther' => [
  239. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  240. ]
  241. ],
  242. 'QY_3L' => [
  243. 'header' => '三市场区域业绩',
  244. 'headerOther' => [
  245. 'width' => '150',
  246. ],
  247. 'value' => function($row) {
  248. return (new Price([
  249. 'value' => $row['QY_3L'],
  250. ]))->result();
  251. },
  252. 'valueOther' => [
  253. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  254. ]
  255. ],
  256. 'SURPLUS_3L' => [
  257. 'header' => '三市场结余业绩',
  258. 'headerOther' => [
  259. 'width' => '150',
  260. ],
  261. 'value' => function($row) {
  262. return (new Price([
  263. 'value' => $row['SURPLUS_3L'],
  264. ]))->result();
  265. },
  266. 'valueOther' => [
  267. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  268. ]
  269. ],
  270. 'CALC_MONTH' => [
  271. 'header' => '结算月',
  272. 'headerOther' => [
  273. 'width' => '110',
  274. ],
  275. ],
  276. ];
  277. }
  278. return $this->columns;
  279. }
  280. /**
  281. * 前台用于筛选的类型集合
  282. * @return mixed
  283. */
  284. public function getFilterTypes()
  285. {
  286. if(!$this->filterTypes){
  287. $this->filterTypes = [];
  288. }
  289. return $this->filterTypes;
  290. }
  291. /**
  292. * 校验大区
  293. * @param $big
  294. * @param $loc
  295. * @param $num
  296. * @return bool
  297. */
  298. private function _chkBig($big, $loc, $num){
  299. return $loc == $num && $big != $loc;
  300. }
  301. }