RegimentRecord.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php namespace App\Http\Controllers\Admin;
  2. use App\Models\Custom as Custom;
  3. use App\Models\Product as Product;
  4. use App\Models\Orders as Orders;
  5. use App\Models\RegimentActive as RegimentActive;
  6. use App\Models\RegimentRecord as Model;
  7. use PhpOffice\PhpSpreadsheet\IOFactory;
  8. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  9. use PhpOffice\PhpSpreadsheet\Style\Alignment;
  10. use PhpOffice\PhpSpreadsheet\Style\Fill;
  11. /**
  12. * 客户签到记录
  13. *
  14. * @author jun
  15. *
  16. */
  17. class RegimentRecord extends Auth{
  18. protected function _initialize(){
  19. parent::_initialize();
  20. $this->assign('breadcrumb1','拼团活动');
  21. $this->assign('breadcrumb2','拼团记录');
  22. }
  23. /**
  24. * 列表页
  25. *
  26. * */
  27. public function index(Model $Model, Product $Product, RegimentActive $RegimentActive, Custom $Custom,Orders $Orders){
  28. // 接收参数
  29. $name = request('name','');
  30. // 查询条件
  31. $map = [];
  32. // 组合条件
  33. if( $name ) $map[] = ['regiment_record.name','=',$name];
  34. $select = [
  35. 'regiment_record.*',
  36. 'regiment.status as regiment_status',
  37. 'regiment_active.name as active_name',
  38. 'product.name as product_name',
  39. 'custom.username as username',
  40. ];
  41. // 查询数据
  42. $list = $Model->query()
  43. ->join('regiment','regiment.id','=','regiment_record.regiment_id')
  44. ->join('regiment_active','regiment_active.id','=','regiment_record.active_id')
  45. ->join('product','product.id','=','regiment_record.product_id')
  46. ->join('custom','custom.uid','=','regiment_record.custom_uid')
  47. ->where($map)
  48. ->select($select)
  49. ->orderByDesc('id')
  50. ->paginate(config('page_num',10));
  51. // 循环处理数据
  52. foreach($list as &$v){
  53. $v['product_code'] = $Product->idToCode($v['product_id']);
  54. $v['active_code'] = $RegimentActive->idToCode($v['active_id']);
  55. $v['custom_code'] = $Custom->idToCode($v['custom_uid']);
  56. $v['order_code'] = $Orders->idToCode($v['order_id']);
  57. }
  58. // 分配数据
  59. $this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
  60. $this->assign('list',$list);
  61. // 加载模板
  62. return $this->fetch();
  63. }
  64. }