12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\admin\controller;
- use think\facade\Db;
- use think\facade\Validate;
- class GoodOfflineLog extends Base
- {
- //列表
- public function getList()
- {
- $param = $this->request->only(['start_date' => '', 'end_date' => '', 'creater' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
- $where = [];
- if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['addtime', 'between', [$param['start_date'], $param['end_date']]];
- if ($param['creater'] != '') $where[] = ['creater', 'like', '%' . $param['creater'] . '%'];
- $count = Db::name('good_offline_log')->where($where)->count('id');
- $list = Db::name('good_offline_log')
- ->field('id,spuCode,good_name,creater,addtime')
- ->where($where)
- ->order('addtime', 'desc')
- ->page($param['page'], $param['size'])
- ->select()
- ->toArray();
- return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
- }
- //详情
- public function getDetail()
- {
- $id = $this->request->post('id', null, 'trim');
- $val = Validate::rule(['id' => 'require|number|gt:0']);
- if (!$val->check(['id' => $id])) return error_show(1004, $val->getError());
- else {
- $res = Db::name('good_offline_log')
- ->alias('gol')
- ->field('gol.*,ri.result')
- ->where('gol.id', $id)
- ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason')
- ->find();
- $res['children_list'] = Db::name('good_platform')
- ->alias('gp')
- ->field('gp.id,gp.skuCode,p.platform_name,g.creater purchease,gp.creater')
- ->where(['gp.spuCode' => $res['spuCode']])
- ->whereIn('gp.skuCode', $res['skuCodes'])
- ->leftJoin('platform p', 'p.id=gp.platform_code')
- ->leftJoin('good g', 'g.spuCode=gp.spuCode')
- ->select()
- ->toArray();
- return app_show(0, "获取成功", $res);
- }
- }
- }
|