params[ 'code' ] ?? ''; $verify_model = new VerifyModel(); $condition = [ [ 'verify_code', '=', $code ], [ 'site_id', '=', $this->site_id ], [ 'store_id', 'in', [0, $this->store_id] ] ]; $info = $verify_model->getVerifyInfo($condition); return $this->response($info); } /** * 核销类型 */ public function verifyType() { $verify_model = new VerifyModel(); $verify_type = $verify_model->getVerifyType(); return $this->response($this->success($verify_type)); } /** * 核销 */ public function verify() { $verify_code = $this->params[ 'verify_code' ] ?? ''; $info = array ( "verifier_id" => $this->uid, "verifier_name" => $this->user_info[ 'username' ], "verify_from" => 'shop', "store_id" => $this->store_id ); $verify_model = new VerifyModel(); $res = $verify_model->verify($info, $verify_code); return $this->response($res); } /** * 核销记录 * @return mixed */ public function recordLists() { $verify_model = new VerifyRecord(); $page = $this->params[ 'page' ] ?? 1; $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS; $verify_type = $this->params[ 'verify_type' ] ?? '';//验证类型 $search_text = $this->params[ 'search_text' ] ?? ''; $start_time = $this->params[ 'start_time' ] ?? ''; $end_time = $this->params[ 'end_time' ] ?? ''; $condition = [ [ 'store_id', '=', $this->store_id ], ]; if (!empty($search_text)) { $condition[] = [ 'verify_code|verifier_name', 'like', '%' . $search_text . '%' ]; } if (!empty($start_time) && empty($end_time)) { $condition[] = [ 'verify_time', '>=', date_to_time($start_time) ]; } elseif (empty($start_time) && !empty($end_time)) { $condition[] = [ 'verify_time', '<=', date_to_time($end_time) ]; } elseif (!empty($start_time) && !empty($end_time)) { $condition[] = [ 'verify_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ]; } $list = $verify_model->getVerifyRecordsPageList($condition, $page, $page_size, '*', 'verify_time desc'); return $this->response($list); } /** * 核销记录详情 * @return false|string */ public function recordsDetail() { $id = $this->params[ 'id' ] ?? 0; $verify_model = new VerifyRecord(); $condition = [ [ 'vr.id', '=', $id ], [ 'vr.store_id', '=', $this->store_id ] ]; $field = 'vr.*,v.verify_type_name,v.expire_time,v.verify_total_count,v.verify_use_num,v.verify_content_json,v.member_id, m.nickname,m.headimg,m.mobile'; $join = [ [ 'verify v', 'v.verify_code = vr.verify_code', 'left' ], [ 'member m', 'v.member_id = m.member_id', 'left' ], ]; $verify_detail = $verify_model->getVerifyRecordsInfo($condition, $field, 'vr', $join)[ 'data' ] ?? []; if (!empty($verify_detail)) { $verify_detail['verify_content_json'] = json_decode($verify_detail['verify_content_json'], true); } return $this->response($this->success($verify_detail)); } }