order('id DESC') ->page((int)$where['page'], (int)$where['limit']) ->select() ->each(function ($item) { $item['create_time'] = ($item['create_time'] != 0 || $item['create_time']) ? date('Y-m-d H:i:s', $item['create_time']) : ""; }); $data = count((array)$data) ? $data->toArray() : []; $count = self::where($batch_where)->count(); return compact('data', 'count'); } /** * 生成会员卡批次二维码 */ public static function qrcodes_url($id = 0, $size = 5) { vendor('phpqrcode.phpqrcode'); $urls = SystemConfigService::get('site_url') . '/'; $url = $urls . 'wap/special/member_manage/type/2/bid/' . $id; $value = $url; //二维码内容 $errorCorrectionLevel = 'H'; //容错级别 $matrixPointSize = $size; //生成图片大小 //生成二维码图片 $filename = self::fileLocation . rand(10000000, 99999999) . '.png'; \QRcode::png($value, $filename, $errorCorrectionLevel, $matrixPointSize, 2); return $urls . $filename; } /**获取单条批次信息 * @param $id * @return array|bool|false|\PDOStatement|string|\think\Model * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function getBatchOne($id) { if (!$id) { return false; } return self::where(['id' => $id])->find(); } public static function getBatchAll(array $where) { if (!$where || !is_array($where)) { $where = array(); } return self::where($where)->select(); } /**增加批次表 * @param array $insert_data * @return bool|int|string */ public static function addBatch(array $insert_data) { if (!$insert_data) { return false; } return self::insertGetId($insert_data); } public function getCreateTimeAttr($time) { return $time;//返回create_time原始数据,不进行时间戳转换。 } public static function delMemberCard($id) { $res = self::where('id', $id)->delete(); $res1 = false; if ($res) { $res1 = MemberCard::where('card_batch_id', $id)->delete(); } $res2 = $res && $res1; return $res2; } }