123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\hander\HelpHander;
- use think\Db;
- class ConveyPlan extends Base {
- public function lists() {
- $lists = Db::name('convey_plan')
- ->where('user_id', $this->userId)
- ->where('org_id', $this->orgId)
- ->where('enable', 1)
- ->where('del', 0)
- ->field('id,name,weeks')
- ->order('id', 'desc')
- ->select();
- $week = date('w');
- $lists = $lists ? $lists : [];
- $newLists = [];
- foreach ($lists as $k => $v) {
- $weeks = $v['weeks'] ? explode(',', $v['weeks']) : [];
- if (in_array($week, $weeks)) {
- $sub = Db::name('convey_plan_addr')
- ->alias('cpa')
- ->where('cpa.plan_id', $v['id'])
- ->join('address ca', 'ca.id = cpa.addr_id')
- ->field('cpa.id,ca.title as name')
- ->order('cpa.sort asc')
- ->select();
- if ($sub) {
- unset($v['weeks']);
- $v['sub'] = $sub;
- $newLists[] = $v;
- }
- }
- }
- HelpHander::success($newLists);
- }
- public function sign() {
- $code = input('code', '');
- if (!$code) {
- HelpHander::error('未上传扫码结果');
- }
- $addrs = model('address')->checkAddrCode($code,2,$this->orgId);
- if(!$addrs){
- HelpHander::error('二维码不正确');
- }
- $data = [
- 'addr_id' => $addrs['id'],
- 'org_id' => $this->orgId,
- 'user_id' => $this->userId,
- 'create_time' => date('Y-m-d H:i:s'),
- 'create_yyyy' => date('Y'),
- 'create_yyyymm' => date('Ym'),
- 'create_yyyymmdd' => date('Ymd')
- ];
- $res = Db::name('convey_plan_record')->insert($data);
- if ($res) {
- HelpHander::success(['addr_id' => $addrs['id']], '操作成功');
- }
- else {
- HelpHander::error('操作失败');
- }
- }
- public function signlist() {
- $page = input('page', 1);
- $size = input('size', 10);
- $offset = ($page - 1) * $size;
- $map[] = ['ocl.org_id', '=', $this->orgId];
- $map[] = ['ocl.user_id', '=', $this->userId];
- $lists = Db::name('convey_plan_record')
- ->alias('ocl')
- ->field('ocl.id,ca.title,ocl.create_time')
- ->join('address ca', 'ca.id = ocl.addr_id')
- ->where($map)
- ->order('ocl.id desc')
- ->limit($offset, $size)
- ->select();
- HelpHander::success($lists ? $lists : []);
- }
- public function sample() {
- $barcode = input('barcode', '');
- $page = input('page', 1);
- $size = input('size', 10);
- $offset = ($page - 1) * $size;
- $map[] = ['ocl.barcode', 'like', '%' . $barcode . '%'];
- $map[] = ['ocl.org_id', '=', $this->orgId];
- $map[] = ['ocl.user_id', '=', $this->userId];
- $lists = Db::name('order_convey_lis')
- ->alias('ocl')
- ->field('ocl.id,ocl.barcode,ca.title,ocl.create_time')
- ->join('address ca', 'ca.id = ocl.addr_id')
- ->where($map)
- ->order('ocl.id desc')
- ->limit($offset, $size)
- ->select();
- HelpHander::success($lists);
- }
- }
|