PerfOrderList.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use backendApi\modules\v1\models\User;
  5. use common\models\User as modelUser;
  6. use common\helpers\Cache;
  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\PerfOrder;
  12. use common\models\Region;
  13. use common\models\UserBind;
  14. use common\models\UserBonus;
  15. use common\models\UserInfo;
  16. use common\libs\dataList\column\DateTime;
  17. use common\models\UserSystem;
  18. use common\models\Withdraw;
  19. use Yii;
  20. class PerfOrderList extends \common\libs\dataList\DataList implements DataListInterface
  21. {
  22. /**
  23. * 列表名称
  24. * @return string
  25. */
  26. public function getListName(){
  27. return '业绩单列表';
  28. }
  29. /**
  30. * 列表筛选到的数据
  31. * @throws \yii\base\Exception
  32. */
  33. public function dataHandle()
  34. {
  35. $data = PerfOrder::lists($this->condition, $this->params, [
  36. 'select'=>'PO.*, U.USER_NAME, U.REAL_NAME',
  37. 'from' => PerfOrder::tableName().' AS PO',
  38. 'join' => [
  39. ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PO.USER_ID=U.ID'],
  40. ],
  41. 'orderBy' => 'PO.CREATED_AT DESC, PO.ID DESC',
  42. 'page' => $this->page,
  43. 'pageSize' => $this->pageSize,
  44. ]);
  45. if($data['list']){
  46. foreach($data['list'] as $key=>$value){
  47. $data['list'][$key]['DEC_STATUS_NAME'] = PerfOrder::STATUS_NAME[$data['list'][$key]['DEC_STATUS']];
  48. }
  49. }
  50. $this->listData = $data;
  51. }
  52. /**
  53. * 要展示和导出的所有字段
  54. * @return array
  55. */
  56. public function getColumn(){
  57. if(!$this->columns){
  58. $this->columns = [
  59. 'PERIOD_NUM' => [
  60. 'header' => '结算期数',
  61. 'headerOther' => [
  62. 'width' => '100',
  63. ],
  64. ],
  65. 'SN' => [
  66. 'header' => '业绩单编号',
  67. 'value' => function($row) {
  68. return "\t".$row['SN'];
  69. },
  70. 'headerOther' => [
  71. 'width' => '250',
  72. ],
  73. ],
  74. 'DEC_TYPE' => [
  75. 'header' => '业绩单类型',
  76. 'headerOther' => [
  77. 'width' => '110',
  78. ],
  79. 'value' => function($row){
  80. $decTypes = [
  81. 'ZC'=> '首购单',
  82. 'YH'=> '优惠单',
  83. 'ZG'=> '增购单',
  84. 'LS'=> '零售单',
  85. 'FX'=> '复销单',
  86. ];
  87. return $decTypes[strtoupper($row['DEC_TYPE'])];
  88. },
  89. ],
  90. 'DEC_STATUS_NAME' => [
  91. 'header' => '业绩单状态',
  92. 'headerOther' => [
  93. 'width' => '110',
  94. ],
  95. ],
  96. 'USER_NAME' => [
  97. 'header' => '会员编号',
  98. 'headerOther' => [
  99. 'width' => '110',
  100. ],
  101. ],
  102. 'REAL_NAME' => [
  103. 'header' => '会员姓名',
  104. 'headerOther' => [
  105. 'width' => '150',
  106. ],
  107. ],
  108. 'LAST_REC_USER_NAME' => [
  109. 'header' => '结算时开拓者编号',
  110. 'headerOther' => [
  111. 'width' => '150',
  112. ],
  113. ],
  114. 'LAST_REC_REAL_NAME' => [
  115. 'header' => '结算时开拓者姓名',
  116. 'headerOther' => [
  117. 'width' => '150',
  118. ],
  119. ],
  120. 'PV' => [
  121. 'header' => '报单PV',
  122. 'headerOther' => [
  123. 'width' => '150',
  124. ],
  125. 'value' => function($row) {
  126. return (new Price([
  127. 'value' => $row['PV'],
  128. ]))->result();
  129. },
  130. ],
  131. 'DEC_AMOUNT' => [
  132. 'header' => '报单金额',
  133. 'headerOther' => [
  134. 'width' => '150',
  135. ],
  136. 'value' => function($row) {
  137. return (new Price([
  138. 'value' => $row['DEC_AMOUNT'],
  139. ]))->result();
  140. },
  141. ],
  142. 'DEC_SN' => [
  143. 'header' => '报单编号',
  144. 'headerOther' => [
  145. 'width' => '250',
  146. ],
  147. ],
  148. 'CREATED_AT' => [
  149. 'header' => '创建时间',
  150. 'value' => function($row) {
  151. return (new DateTime([
  152. 'value' => $row['CREATED_AT'],
  153. ]))->result();
  154. },
  155. 'headerOther' => ['width' => '170'],
  156. ],
  157. ];
  158. }
  159. return $this->columns;
  160. }
  161. /**
  162. * 前台用于筛选的类型集合
  163. * @return mixed
  164. */
  165. public function getFilterTypes()
  166. {
  167. if(!$this->filterTypes){
  168. $this->filterTypes = [
  169. 'PERIOD_NUM'=> ['isUserTable'=> false, 'name'=> '结算期数'],
  170. 'SN'=> ['isUserTable'=> false, 'name'=> '业绩单编号'],
  171. 'DEC_STATUS_NAME'=> ['isUserTable'=> false, 'name'=> '业绩单状态','other'=> 'select',
  172. 'selectData'=> [['id'=> 1, 'name'=> '已审核'], ['id'=> 2, 'name'=> '置废']],],
  173. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
  174. 'REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
  175. 'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '结算时开拓者编号'],
  176. 'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '结算时开拓者姓名'],
  177. 'PV'=> ['isUserTable'=> false, 'name'=> '报单PV'],
  178. 'DEC_AMOUNT'=> ['isUserTable'=> false, 'name'=> '报单金额'],
  179. 'DEC_SN'=> ['isUserTable'=> false, 'name'=> '报单编号'],
  180. 'CREATED_AT'=> ['isUserTable'=> true, 'name'=> '创建时间', 'other'=> 'date'],
  181. ];
  182. }
  183. return $this->filterTypes;
  184. }
  185. }