getUser(); $user['collection_count'] = DataCollectionLog::mk()->where('uuid',$this->uuid)->where('cate',1)->whereNotIn('type',[3,4])->count(); $this->success('获取用户资料', $user); } /** * @Title("平台规则") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * * @Returned("platform_rules",desc="平台规则") */ public function getplatformrules(){ $info= [ 'platform_rules'=>htmlspecialchars_decode(sysconf('platform.platform_rules')), ]; $this->success('成功',$info); } /** * @Title("Base64图片上传") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=0,default="",desc="token") * @Returned("url",desc="图片地址") */ public function image() { try { $data = $this->_vali(['base64.require' => '图片内容不为空!']); if (preg_match($preg = '|^data:image/(.*?);base64,|i', $data['base64'])) { [$ext, $img] = explode('|||', preg_replace($preg, '$1|||', $data['base64'])); if (empty($ext) || !in_array(strtolower($ext), ['png', 'jpg', 'jpeg'])) { $this->error('图片格式异常!'); } $name = Storage::name($img, $ext, 'image/'); $info = Storage::instance()->set($name, base64_decode($img)); $this->success('图片上传成功!', ['url' => $info['url']]); } else { $this->error('解析内容失败!'); } } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { trace_file($exception); $this->error($exception->getMessage()); } } /** * @Title("二进制图片、文件上传") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=0,default="",desc="token") * @Param("file",type="file",require=1,default="",desc="文件") * @Returned("url",desc="图片地址") */ public function upload() { ini_set ("memory_limit","-1"); $file = $this->request->file('file'); if (empty($file)) $this->error('文件上传异常!'); $extension = strtolower($file->getOriginalExtension()); if (in_array($extension, ['php', 'sh'])) $this->error('禁止上传此类文件!'); $bina = file_get_contents($file->getRealPath()); $name = Storage::name($file->getPathname(), $extension, '', 'md5_file'); $info = Storage::instance()->set($name, $bina, false, $file->getOriginalName()); if (is_array($info) && isset($info['url'])) { $this->success('文件上传成功!', $info); } else { $this->error('文件上传失败!'); } } /** * @Title("二进制图片、文件上传多个") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=0,default="",desc="token") * @Param("file[]",type="file",require=1,default="",desc="文件") * @Returned("url",desc="图片地址") */ public function uploadmore() { ini_set ("memory_limit","-1"); $file = $this->request->file('file'); if (empty($file)) $this->error('文件上传异常!'); $array = []; foreach ($file as $file){ $extension = strtolower($file->getOriginalExtension()); if (in_array($extension, ['php', 'sh'])) $this->error('禁止上传此类文件!'); $bina = file_get_contents($file->getRealPath()); $name = Storage::name($file->getPathname(), $extension, '', 'md5_file'); $info = Storage::instance()->set($name, $bina, false, $file->getOriginalName()); array_push($array,$info); } $this->success('文件上传成功!', $array); } /** * @Title("更新用户资料") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("headimg",type="string",require=0,default="",desc="头像") * @Param("nickname",type="string",require=0,default="",desc="昵称") * @Param("email",type="string",require=0,default="",desc="邮箱") * @Param("base_sex",type="string",require=0,default="",desc="性别") */ public function set() { $data = $this->_vali([ 'headimg.default' => '', 'nickname.default' => '', 'email.default' => '', 'base_sex.default' => '', ]); foreach ($data as $key => $vo) if ($vo === '') unset($data[$key]); if (empty($data)) $this->error('没有修改的数据!'); if (DataUser::mk()->where(['id' => $this->uuid])->update($data) !== false) { $this->success('更新资料成功!', $this->getUser()); } else { $this->error('更新资料失败!'); } } /** * @Title("修改密码") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("password",type="string",require=0,default="",desc="原密码") * @Param("newpassword",type="string",require=0,default="",desc="新密码") */ public function uppass() { $data = $this->_vali([ 'password.require'=>'原密码必须', 'newpassword.require'=>'新密码必须' ]); if ($data['password']==$data['newpassword']) $this->error('原密码与新密码一样'); $pass = DataUser::mk()->where('id',$this->uuid)->value('password'); if (md5($data['password'])!=$pass) $this->error('原密码验证错误'); if (DataUser::mk()->where(['id' => $this->uuid])->update(['password'=>md5($data['newpassword'])]) !== false) { $this->success('更新密码成功!', $this->getUser()); } else { $this->error('更新密码失败!'); } } /** * @Title("获取开通vip配置信息") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * * @Returned("price",desc="价格") * @Returned("user_vip_des",desc="会员权益说明") * @Returned("user_vip_agreement",desc="会员服务协议") */ public function getvipinfo(){ $info= [ 'price'=>sysconf('user_vip.price'), 'user_vip_des'=>htmlspecialchars_decode(sysconf('user_vip.user_vip_des')), 'user_vip_agreement'=>htmlspecialchars_decode(sysconf('user_vip.user_vip_agreement')), ]; $this->success('成功',$info); } /** * @Title("获取支付方式") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * * @Param("type",type="string",require=1,default="",desc="1:开通会员vip 2:商城、充值") * @Param("from",type="string",require=1,default="",desc="1:微信小程序 2:APP") */ public function channel() { $data = $this->_vali([ 'type.require|in:1,2'=>'type有误', 'from.require|in:1,2'=>'来源有误' ]); $type = $data['type']; $from = $data['from']; // 读取支付通道配置 $query = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0]) ->when($type,function ($query) use ($type){ if ($type==2){ $query->where('type','<>','balance'); } })->where(function ($query) use ($from){ if ($from==1){ $query->whereNotIn('type',['wechat_app','alipay_app']); }else{ $query->where('type','<>','wechat_xcx'); } }); //$query->whereIn('code', str2arr($payments))->whereIn('type', PaymentService::getTypeApi($this->type)); $result = $query->order('sort desc,id desc')->column('type,code,name,cover,content,remark', 'code'); foreach ($result as &$vo) $vo['content'] = ['voucher_qrcode' => json_decode($vo['content'])->voucher_qrcode ?? '']; $this->success('获取支付参数数据', array_values($result)); } /** * @Title("开通会员") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("pay_code",type="string",require=1,default="",desc="支付方式code") * @Param("difference_pay_code",type="string",require=0,default="",desc="余额支付时,差价支付方式code") * */ public function openvip(){ $user = $this->getUser(); $data = $this->_vali([ 'pay_code.require'=>'支付code有误', 'difference_pay_code.default'=>'' ]); $code = $data['pay_code']; $difference_pay_code = $data['difference_pay_code']; $pay_type = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0,'code'=>$code])->value('type') ? : $this->error('支付找不到'); $all_price = sysconf('user_vip.price'); $order_no = setorderno($this->uuid); $insert = [ 'uuid'=>$this->uuid, 'order_no'=>$order_no, 'all_price'=>$all_price, 'pay_type'=>$pay_type ]; $error = 1; Db::startTrans(); $retrun_data = []; try { if ($pay_type=='balance'){ if ($user['money']<$all_price){ if (empty($difference_pay_code) || !isset($difference_pay_code)){ $error = 0; $errorinfo = '余额不足'; }else{ $difference_pay_type = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0,'code'=>$difference_pay_code])->value('type'); if (!$difference_pay_type){ $error = 0; $errorinfo = '差价支付找不到'; }else{ $all_price = bcsub($all_price,$user['money'],2); $insert['yue_price'] = $user['money']; $insert['difference_money'] = $all_price; $insert['difference_pay_type'] = $difference_pay_type; $code = $difference_pay_code; $pay_type = $difference_pay_type; } } } } $order_id = DataUserVipOrder::mk()->insertGetId($insert); if (stripos($pay_type, 'alipay_') === 0) { $notify_name = 'opvipzfb'; } elseif (stripos($pay_type, 'wechat_') === 0) { $notify_name = 'opvipwx'; } else{ $notify_name = 'opvip'; } $notify_url = sysuri("@data/api.notify/{$notify_name}/scene/order/param/{$code}", [], false, true); $parm = ['uuid'=>$this->uuid,'order_id'=>$order_id]; $pay =PaymentService::instance($code)->create($user['openid1'],$order_no,$all_price,'开通vip','开通vip','','',$notify_url,$parm); $retrun_data['order_no'] = $order_no; $pay['packages'] = isset($pay['package']) ? $pay['package'] : ''; $retrun_data['pay'] = $pay; $retrun_data['success'] = isset($pay['result']) && $pay['result']=='success' ? 1 : 0; Db::commit(); } catch (\Exception $e) { dump($e); // 回滚事务 Db::rollback(); $error = 0; $errorinfo = '未知错误'; } if ($error){ $this->success('成功',$retrun_data); } $this->error($errorinfo); } /** * @Title("人才库职称列表") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") */ public function zclist() { $list = DataZhicheng::Show()->select(); $this->success('成功',$list); } /** * @Title("加入人才库/编辑人才库") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("name",type="string",require=1,default="",desc="姓名") * @Param("sex",type="string",require=1,default="",desc="性别") * @Param("age",type="string",require=1,default="",desc="年龄") * @Param("jg",type="string",require=1,default="",desc="籍贯") * @Param("phone",type="string",require=1,default="",desc="手机号") * @Param("email",type="string",require=1,default="",desc="邮箱") * @Param("province",type="string",require=1,default="",desc="省") * @Param("city",type="string",require=1,default="",desc="市") * @Param("area",type="string",require=1,default="",desc="区/镇") * @Param("address",type="string",require=1,default="",desc="详细地址") * @Param("graduate_school",type="string",require=1,default="",desc="毕业院校") * @Param("xl",type="string",require=1,default="",desc="学历") * @Param("major",type="string",require=1,default="",desc="专业") * @Param("working_life",type="string",require=1,default="",desc="工作年限") * @Param("tc",type="string",require=1,default="",desc="特长") * @Param("jn",type="string",require=1,default="",desc="技能") * @Param("zc_id",type="string",require=1,default="",desc="职称ID") * @Param("zz_imgs",type="string",require=1,default="",desc="资质证书,多个以逗号隔开") * @Param("pxjl",type="string",require=1,default="",desc="培训经历") * @Param("id",type="string",require=0,default="",desc="审核失败,修改,则必传之前提交的ID") */ public function adduppooltalent() { $data = $this->_vali([ 'uuid.default'=>$this->uuid, 'name.require'=>'姓名必须', 'sex.require'=>'性别必须', 'age.require|number|between:1,120'=>'年龄必须,1-120', 'jg.require'=>'籍贯必须', 'phone.require'=>'手机号必须', 'email.require'=>'邮箱必须', 'province.require'=>'省必须', 'city.require'=>'市必须', 'area.require'=>'区/镇必须', 'address.require'=>'详细地址必须', 'graduate_school.require'=>'毕业院校必须', 'xl.require'=>'学历必须', 'working_life.require'=>'工作年限必须', 'major.require'=>'专业必须', 'tc.require'=>'特长必须', 'jn.require'=>'技能必须', 'zc_id.require|number'=>'职称必须', 'zz_imgs.require'=>'资质证书必须', 'pxjl.require'=>'培训经历必须', ],'post'); $id = input('id'); if (!Validate::regex($data['phone'], "^1\d{10}$")) { $this->error('手机号格式错误'); } DataZhicheng::mk()->where('id',$data['zc_id'])->where('is_del',1)->count() ? : $this->error('职称不存在'); empty($id) ? $id = DataPoolTalent::mk()->where('uuid',$this->uuid)->value('id') : $data['update_at']=date('Y-m-d H:i:s'); DataPoolTalent::mk()->where('uuid',$this->uuid)->value('audit') == 3 ? $data['audit'] =1 : ''; if (empty($id) ? DataPoolTalent::mk()->insert($data) : DataPoolTalent::mk()->where('id',$id)->update($data)){ $this->success('提交成功'); } $this->error('提交失败,请稍后重试'); } /** * @Title("添加人才库工作经历/编辑人才库工作经历") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="工作经历ID,编辑时穿") * @Param("content",type="json",require=0,default="",desc="工作经历json,(company_name:公司名称,position_name:职位名称,on_job_start:在职时间开始,on_job_end:在职时间结束,job_description:工作内容)") */ public function adduppooltalentchild() { $data = $this->_vali([ 'id.default'=>'', 'content.require'=>'工作经历必须', ]); $info_id = DataPoolTalent::mk()->where('uuid',$this->uuid)->value('id') ? : DataPoolTalent::mk()->insertGetId(['uuid'=>$this->uuid]); $child_id = $data['id']; $child_array = [ 'info_id'=>$info_id, 'content'=>$data['content'] ]; !empty($child_id) ? $child_array['update_at'] = date('Y-m-d H:i:s') : ''; if (!empty($child_id) ? DataPoolTalentChild::mk()->where('id',$child_id)->update($child_array) : DataPoolTalentChild::mk()->insert($child_array)){ $this->success('成功'); } $this->error('失败'); } /** * @Title("人才库工作经历删除") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="ID") */ public function delpooltalentchild(){ $data = $this->_vali([ 'id.require'=>'id必须', ]); if (DataPoolTalentChild::mk()->where('id',$data['id'])->delete()){ $this->success('成功'); } $this->error('失败'); } /** * @Title("申请维修工/编辑维修工") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("name",type="string",require=1,default="",desc="姓名") * @Param("id_card",type="string",require=1,default="",desc="身份证号") * @Param("email",type="string",require=1,default="",desc="邮箱") * @Param("province",type="string",require=1,default="",desc="省") * @Param("city",type="string",require=1,default="",desc="市") * @Param("area",type="string",require=1,default="",desc="区/镇") * @Param("address",type="string",require=1,default="",desc="详细地址") * @Param("id_card_img1",type="string",require=1,default="",desc="身份证人面照片") * @Param("id_card_img2",type="string",require=1,default="",desc="身份证国徽面照片") * @Param("business_img",type="string",require=1,default="",desc="营业执照图片") * @Param("authorization_img",type="string",require=0,default="",desc="厂家授权图片") * @Param("results",type="string",require=1,default="",desc="以往业绩") * @Param("id",type="string",require=0,default="",desc="审核失败,修改,则必传之前提交的ID") */ public function addupmaintenance() { $data = $this->_vali([ 'uuid.default'=>$this->uuid, 'name.require'=>'姓名必须', 'id_card.require'=>'身份证号必须', 'email.require'=>'邮箱必须', 'province.require'=>'省必须', 'city.require'=>'市必须', 'area.require'=>'区/镇必须', 'address.require'=>'详细地址必须', 'id_card_img1.require'=>'身份证人面照片必须', 'id_card_img2.require'=>'身份证国徽面照片必须', 'business_img.require'=>'营业执照图片必须', 'authorization_img.default'=>'', 'results.require'=>'以往业绩必须', ]); if (!check_idcard($data['id_card'])) $this->error('身份证号格式错误'); $id = input('id'); !empty($id) ? : (DataMaintenance::mk()->where('uuid',$this->uuid)->count() ? $this->error('已经提交过') : '' ); empty($id) ? : $data['update_at']=date('Y-m-d H:i:s'); DataMaintenance::mk()->where('uuid',$this->uuid)->value('audit') == 3 ? $data['audit'] =1 : ''; if (empty($id) ? DataMaintenance::mk()->insert($data) : DataMaintenance::mk()->where('id',$id)->update($data)){ $this->success('提交成功'); } $this->error('提交失败,请稍后重试'); } /** * @Title("申请船厂/编辑船厂") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("name",type="string",require=1,default="",desc="船厂名称") * @Param("head_img",type="string",require=1,default="",desc="船厂头像") * @Param("province",type="string",require=1,default="",desc="省") * @Param("city",type="string",require=1,default="",desc="市") * @Param("area",type="string",require=1,default="",desc="区/镇") * @Param("address",type="string",require=1,default="",desc="详细地址") * @Param("contact_name",type="string",require=1,default="",desc="联系人") * @Param("contact_phone",type="string",require=1,default="",desc="联系电话") * @Param("intro",type="string",require=1,default="",desc="船厂简介") * @Param("longitude",type="string",require=1,default="",desc="经度") * @Param("latitude",type="string",require=1,default="",desc="维度") * @Param("environment_imgs",type="string",require=1,default="",desc="船厂环境,多个以英文逗号隔开") * @Param("product_intro",type="string",require=1,default="",desc="产品简介") * @Param("business_img",type="string",require=1,default="",desc="营业执照") * @Param("num_staff",type="string",require=1,default="",desc="员工人数") * @Param("id",type="string",require=0,default="",desc="审核失败,修改,则必传之前提交的ID") */ public function addupshipyard() { $data = $this->_vali([ 'uuid.default'=>$this->uuid, 'name.require'=>'船厂名称必须', 'longitude.require'=>'经纬度必须', 'longitude.float'=>'经纬度有误', 'latitude.require'=>'经纬度必须', 'latitude.float'=>'经纬度有误', 'head_img.require'=>'船厂头像必须', 'province.require'=>'省必须', 'city.require'=>'市必须', 'area.require'=>'区/镇必须', 'address.require'=>'详细地址必须', 'contact_name.require'=>'联系人必须', 'contact_phone.require'=>'联系电话必须', 'intro.require'=>'船厂简介必须', 'environment_imgs.require'=>'船厂环境必须', 'product_intro.require'=>'产品简介必须', 'business_img.require'=>'营业执照必须', 'num_staff.require'=>'人数必须', ]); $id = input('id'); !empty($id) ? : (DataShipyard::mk()->where('uuid',$this->uuid)->count() ? $this->error('已经提交过') : '' ); empty($id) ? : $data['update_at']=date('Y-m-d H:i:s'); DataShipyard::mk()->where('uuid',$this->uuid)->value('audit') == 3 ? $data['audit'] =1 : ''; if (empty($id) ? DataShipyard::mk()->insert($data) : DataShipyard::mk()->where('id',$id)->update($data)){ $this->success('提交成功'); } $this->error('提交失败,请稍后重试'); } /** * @Title("申请商家/编辑商家") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("name",type="string",require=1,default="",desc="商家名称") * @Param("head_img",type="string",require=1,default="",desc="商家头像") * @Param("province",type="string",require=1,default="",desc="省") * @Param("city",type="string",require=1,default="",desc="市") * @Param("area",type="string",require=1,default="",desc="区/镇") * @Param("address",type="string",require=1,default="",desc="详细地址") * @Param("longitude",type="string",require=1,default="",desc="经度") * @Param("latitude",type="string",require=1,default="",desc="纬度") * @Param("address",type="string",require=1,default="",desc="详细地址") * @Param("contact_name",type="string",require=1,default="",desc="联系人") * @Param("contact_phone",type="string",require=1,default="",desc="联系电话") * @Param("intro",type="string",require=1,default="",desc="商家简介") * @Param("imgs_videos",type="string",require=1,default="",desc="图片及视频,以英文逗号隔开") * @Param("business_img",type="string",require=1,default="",desc="营业执照") * @Param("id",type="string",require=0,default="",desc="审核失败,修改,则必传之前提交的ID") */ public function addupmerchants() { $data = $this->_vali([ 'uuid.default'=>$this->uuid, 'name.require'=>'商家名称必须', 'head_img.require'=>'商家头像必须', 'province.require'=>'省必须', 'city.require'=>'市必须', 'area.require'=>'区/镇必须', 'address.require'=>'详细地址必须', 'longitude.require'=>'经纬度必须', 'latitude.require'=>'经纬度必须', 'contact_name.require'=>'联系人必须', 'contact_phone.require'=>'联系电话必须', 'intro.require'=>'商家简介必须', 'imgs_videos.require'=>'图片及视频必须', 'business_img.require'=>'营业执照必须', ]); $id = input('id'); !empty($id) ? : (DataMerchants::mk()->where('uuid',$this->uuid)->count() ? $this->error('已经提交过') : '' ); empty($id) ? : $data['update_at']=date('Y-m-d H:i:s'); DataMerchants::mk()->where('uuid',$this->uuid)->value('audit') == 3 ? $data['audit'] =1 : ''; if (empty($id) ? DataMerchants::mk()->insert($data) : DataMerchants::mk()->where('id',$id)->update($data)){ $this->success('提交成功'); } $this->error('提交失败,请稍后重试'); } /** * @Title("阿里云金融级实名认证初始化") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("username",type="string",require=1,default="",desc="真实姓名") * @Param("id_card",type="string",require=1,default="",desc="身份证号") * @Param("MetaInfo",type="string",require=1,default="",desc="metainfo") * @Param("ReturnUrl",type="string",require=1,default="",desc="返回地址") */ public function initFaceVerify(){ $user = $this->getUser(); //if ($user['is_auth']) $this->error('已实名认证'); $data = $this->_vali([ 'username.require'=>'真实姓名必须', 'id_card.require'=>'身份证号必须', 'MetaInfo.require'=>'metainfo必须', 'ReturnUrl.default'=>'2222' ]); if (!isCreditNo($data['id_card'])) $this->error('身份证号格式错误'); DataUser::mk()->where('id_card',$data['id_card'])->count() ? $this->error('身份证号已认证过') : ''; $res = main($data['username'],$data['id_card'],$data['MetaInfo'],$data['ReturnUrl']); if(!$res) $this->error('初始化错误'); $result = json_decode(json_encode($res),true)['body']; $result['code'] != 200 ? $this->error($result['message']):$this->success('获取成功',$result); } /** * @Title("实名认证") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("username",type="string",require=1,default="",desc="真实姓名") * @Param("id_card",type="string",require=1,default="",desc="身份证号") * @Param("CertifyId",type="string",require=1,default="",desc="CertifyId") */ public function userCertification() { $user = $this->getUser(); if ($user['is_auth']) $this->error('已实名认证'); $data = $this->_vali([ 'username.require'=>'真实姓名必须', 'id_card.require'=>'身份证号必须', 'is_auth.default'=>1, 'CertifyId.require'=>'CertifyId必须' ]); if (!isCreditNo($data['id_card'])) $this->error('身份证号格式错误'); DataUser::mk()->where('id_card',$data['id_card'])->count() ? $this->error('身份证号已认证过') : ''; $data['real_name']=$data['username']; unset($data['username']); // 核验 $res = check($data['CertifyId']); if(!$res) $this->error('认证失败'); $result = json_decode(json_encode($res),true)['body']; if($result['code'] != 200) $this->error($result['message']); unset($data['CertifyId']); if (DataUser::mk()->where(['id' => $this->uuid])->update($data) !== false) { $this->success('实名认证成功!'); } else { $this->error('实名认证失败!'); } } /** * @Title("钱包-我的余额") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") */ public function moneylog(){ $user = $this->getUser(); $list = DataUserMoneyLog::Show($this->uuid)->paginate(); $money = $user['money']; $bank_count = DataUserBankCard::Show($this->uuid)->count(); $this->success('成功',compact('money','bank_count','list')); } /** * @Title("钱包-我的银行卡列表") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") */ public function mybanklist(){ $list = DataUserBankCard::Show($this->uuid)->select(); $this->success('成功',$list); } /** * @Title("绑定银行卡") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("name",type="string",require=1,default="",desc="姓名") * @Param("id_card",type="string",require=1,default="",desc="银行卡号") * @Param("id",type="string",require=0,default="",desc="修改,则必传之前提交的ID") */ public function bind_bank(){ $data = $this->_vali([ 'uuid'=>$this->uuid, 'name.require'=>'姓名必须', 'id_card.require'=>'卡号必须', ]); !checkbank($data['id_card']) ? $this->error('卡号不正确') : ''; $bank_name = bankInfo($data['id_card']); empty($bank_name) ? $this->error('卡号不正确或未录入') : ''; $data['card_name'] = $bank_name; $id = input('id'); DataUserBankCard::Show($this->uuid,$data['id_card'],$id)->count() ? $this->error('卡号已存在') : ''; empty($id) ? : $data['update_at']=date('Y-m-d H:i:s'); if (empty($id) ? DataUserBankCard::mk()->insert($data) : DataUserBankCard::mk()->where('id',$id)->update($data)){ $this->success('提交成功'); } $this->error('提交失败,请稍后重试'); } /** * @Title("删除银行卡") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=0,default="",desc="修改,则必传之前提交的ID") */ public function delbank(){ $data = $this->_vali([ 'id.require'=>'id必须', ]); if (DataUserBankCard::mk()->where('id',$data['id'])->update(['is_del'=>0,'update_at'=>date('Y-m-d H:i:s')])){ $this->success('删除成功'); } $this->error('删除失败,请稍后重试'); } /** * @Title("获取提现信息") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * * @Returned("withdraw_min_price",desc="最低提现金额") * @Returned("withdraw_max_price",desc="最大提现金额") * @Returned("poundage_proportion",desc="手续费百分比") * @Returned("money",desc="用户可提现余额") */ public function getwithinfo(){ $user = $this->getUser(); $info= [ 'withdraw_min_price'=>sysconf('user.withdraw_min_price'), 'withdraw_max_price'=>sysconf('user.withdraw_max_price'), 'poundage_proportion'=>sysconf('user.poundage_proportion'), 'money'=>$user['money'] ]; $this->success('成功',$info); } /** * @Title("提现") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("money",type="string",require=1,default="",desc="提现金额") * @Param("bind_id",type="string",require=0,default="",desc="绑定的银行卡记录ID") */ public function withdraw(){ $user=$this->getUser(); $data = $this->_vali([ 'money.require'=>'金额必须', 'bind_id.require'=>'绑定的记录ID必须', ]); $money = $data['money']; isAmount($money) ? : $this->error('金额错误'); $user['money']<$money ? $this->error('余额不足') : ''; $bank = DataUserBankCard::mk()->where('id',$data['bind_id'])->where('uuid',$this->uuid)->where('is_del',1)->findOrEmpty(); if ($bank->isEmpty()) $this->error('绑定记录不存在'); $withdraw_min_price = sysconf('user.withdraw_min_price'); //最小提现金额 $withdraw_max_price = sysconf('user.withdraw_max_price'); //最大提现金额 $poundage_proportion = sysconf('user.poundage_proportion'); //手续费百分比 $money < $withdraw_min_price ? $this->error('最低提现'.$withdraw_min_price.'元') : ''; $money > $withdraw_max_price ? $this->error('最大提现'.$withdraw_min_price.'元') : ''; $error = 1; Db::startTrans(); try { $proportion = sprintf("%.2f", $money*($poundage_proportion/100)); //四舍五入保留两位小数点 $real_money = bcsub($money,$proportion,2); $inset = [ 'uuid'=>$this->uuid, 'order_no'=>setorderno($this->uuid), 'bink_id'=>$data['bind_id'], 'card_name'=>$bank['card_name'], 'name'=>$bank['name'], 'bank_id_card'=>$bank['id_card'], 'price'=>$money, 'poundage_proportion'=>$poundage_proportion, 'proportion'=>$proportion, 'real_money'=>$real_money ]; $id = DataUserWithdraw::mk()->insertGetId($inset); //余额提现 $res = userMoneyChange($money,1,$this->uuid,'余额提现',0,$id); if (!$res){ $error = 0; $errorinfo = '提现失败'; Db::rollback(); } Db::commit(); } catch (\Exception $e) { // 回滚事务 Db::rollback(); $error = 0; $errorinfo = '未知错误'; } if ($error){ $this->success('提现成功,等待审核'); } $this->error($errorinfo); } /** * @Title("意见反馈列表") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("page&limit",type="string",require=0,default="",desc="分页") */ public function feedbacklist(){ $list = DataFeedback::Show($this->uuid)->with(['reply'])->paginate(); $this->success('成功',$list); } /** * @Title("意见反馈提交") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("content",type="string",require=1,default="",desc="反馈内容") * @Param("imgs",type="string",require=0,default="",desc="图片,以逗号隔开") * @Param("phone",type="string",require=0,default="",desc="手机号") * @Param("id",type="string",require=0,default="",desc="修改,则必传之前提交的ID,只有未回复的能修改") */ public function subfeedback(){ $data = $this->_vali([ 'uuid'=>$this->uuid, 'content.require'=>'反馈内容必须', 'imgs.default'=>'', 'phone.default'=>'' ]); empty($id) ? : $data['update_at']=date('Y-m-d H:i:s'); if (empty($id) ? DataFeedback::mk()->insert($data) : DataFeedback::mk()->where('id',$id)->update($data)){ $this->success('提交成功'); } $this->error('提交失败,请稍后重试'); } /** * @Title("意见反馈删除") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="反馈ID") */ public function delfeedback(){ $data = $this->_vali([ 'id.require'=>'ID必须', 'is_del.default'=>'0', ]); $id = $data['id']; unset($data['id']); DataFeedback::Show($this->uuid,$id)->count() ? '' : $this->error('信息不存在'); if (DataFeedback::mk()->where('id',$id)->update($data)){ $this->success('删除成功'); } $this->error('删除失败,请稍后重试'); } /** * @Title("我的收藏列表") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("type",type="string",require=1,default="",desc="1:知识教学2:百知文库3:采购订单4应聘信息,5:船厂") * @Param("longitude",type="string",require=1,default="",desc="经度,船厂必须") * @Param("latitude",type="string",require=1,default="",desc="纬度,船厂必须") * @Returned("shipyard",desc="船厂对象") * @Returned("shipyard.distance",desc="船厂距离你的距离km") */ public function mycollection(){ $data = $this->_vali([ 'type.require|in:1,2,3,4,5'=>'type有误' ]); switch ($data['type']){ case 1: $list = DataCollectionLog::mk() ->hasWhere('knowledge',function (Query $query){ $query->where('is_del',1); }) ->where('data_collection_log.uuid',$this->uuid) ->where('cate',1) ->where('data_collection_log.type',1) ->with(['knowledge'=>function($query){ $query->with(['user'=>function($query){ $query->field('id,nickname,headimg,is_auth,is_vip'); }]); }]) ->order('id desc') ->paginate(); break; case 2: $list = DataCollectionLog::mk() ->hasWhere('knowledge',function (Query $query){ $query->where('is_del',1); }) ->where('data_collection_log.uuid',$this->uuid) ->where('cate',2) ->where('data_collection_log.type',2) ->with(['knowledge'=>function($query){ $query->with(['user'=>function($query){ $query->field('id,nickname,headimg,is_auth,is_vip'); }]); }]) ->order('id desc') ->paginate(); break; case 3: $list = ShopFavourite::mk() ->where('user_id',$this->uuid) ->order('id desc') ->paginate() ->toArray(); foreach ($list['data'] as &$v){ switch ($v['target_type']){ case 'shop_purchase': $v['info'] = ShopPurchase::mk() ->where('id',$v['target_id']) ->with(['items','merchant']) ->findOrFail(); break; case 'shop_production': $v['info'] = ShopProduction::mk() ->where('id',$v['target_id']) ->with(['items','merchant']) ->findOrFail(); break; case 'shop_coordination': $v['info'] = ShopCoordination::mk() ->where('id',$v['target_id']) ->with(['items','merchant']) ->findOrFail(); break; case 'shop_ocean': $v['info'] = ShopOcean::mk() ->where('id',$v['target_id']) ->with(['items','merchant']) ->findOrFail(); break; } } break; case 4: $list = []; break; case 5: $data = $this->_vali([ 'longitude.require'=>'经度必须', 'longitude.float'=>'经纬度必须是数字', 'latitude.require'=>'纬度必须', 'latitude.float'=>'经纬度必须是数字', ]); $list = DataCollectionLog::hasShipyard() ->where('uuid',$this->uuid) ->with(['shipyard']) ->paginate(); foreach ($list as $item){ $item['shipyard']->makeDistance($data['longitude'],$data['latitude']); } break; } $this->success('成功',$list); } /** * @Title("我的发布列表") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("type",type="string",require=1,default="",desc="1:知识教学2:百知文库3:应聘信息") * @Returned("audit",desc="1:待审核2:审核成功3:审核失败") * @Returned("why",desc="审核失败原因") */ public function myrelease(){ $data = $this->_vali([ 'type.require|in:1,2,3'=>'type有误' ]); switch ($data['type']){ case 1: $list = DataTeachingKnowledge::mk() ->where('uuid',$this->uuid) ->where('is_del',1) ->with(['user'=>function($query){ $query->field('id,headimg,nickname'); }]) ->order('id desc') ->paginate(); break; case 2: $list = DataBestKnowledge::mk() ->where('uuid',$this->uuid) ->where('is_del',1) ->with(['user'=>function($query){ $query->field('id,headimg,nickname'); },'classTo']) ->paginate(); break; case 3: $list = DataUserApplyJobInfo::mk() ->where('uuid',$this->uuid) ->with(['workexperience','professionalskills','certificate']) ->findOrEmpty(); if (!isset($list['id'])) $list = null; break; } $this->success('成功',$list); } /** * @Title("应聘信息隐藏,取消隐藏") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("hidden",type="string",require=1,default="",desc="0:隐藏 1:显示") */ public function canhidden(){ $data = $this->_vali([ 'hidden.require|in:0,1'=>'字段有误', 'update_at.default'=>date('Y-m-d H:i:s') ]); DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->findOrEmpty() ? : $this->error('未提交') ; if (DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->update($data)){ $this->success('成功'); } $this->error('失败'); } /** * @Title("我的需求") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("type",type="string",require=1,default="",desc="1:采购接单需求2:船机修理接单需求") */ public function myneed(){ $data = $this->_vali([ 'type.require|in:1,2'=>'字段有误', ]); switch ($data['type']){ case 1: $info = DataUserPurchaseAcceptance::mk() ->where('uuid',$this->uuid) ->findOrEmpty(); if (!isset($info['id'])) $info = null; break; case 2: $info = DataUserAcceptance::mk() ->where('uuid',$this->uuid) ->findOrEmpty(); break; } $this->success('成功',$info); } /** * @Title("发布、修改采购接单需求") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("description",type="string",require=1,default="",desc="需求说明") * @Param("business_img",type="string",require=1,default="",desc="营业执照或身份证照") * @Param("imgs",type="string",require=1,default="",desc="图片及资质证件图片,多个以英文逗号隔开") * @Param("hidden",type="string",require=0,default="1",desc="是否隐藏1:不隐藏 2:隐藏") * @Param("province",type="string",require=1,default="",desc="定位-省") * @Param("city",type="string",require=1,default="",desc="定位-市") * @Param("area",type="string",require=1,default="",desc="定位-区") * @Param("id",type="string",require=0,default="",desc="修改时,传ID") */ public function subpurchaseacceptance(){ $data = $this->_vali([ 'uuid.default'=>$this->uuid, 'description.require'=>'需求说明必须', 'business_img.require'=>'营业执照或身份证照必须', 'imgs.require'=>'图片及资质证件图片必须', 'province.require'=>'定位-省', 'city.require'=>'定位-市', 'area.require'=>'定位-区', 'hidden.default'=>1 ]); $id = input('id'); empty($id) ? $id = DataUserPurchaseAcceptance::mk()->where('uuid',$this->uuid)->value('id') : '' ; empty($id) ? : $data['update_at']=date('Y-m-d H:i:s'); empty($id) ? : $data['create_at']=date('Y-m-d H:i:s'); !empty($id) ? (DataUserPurchaseAcceptance::mk()->where('uuid',$this->uuid)->where('id',$id)->value('status') == 2 ? $data['status'] = 0: '') : ''; if (empty($id) ? DataUserPurchaseAcceptance::mk()->insert($data) : DataUserPurchaseAcceptance::mk()->where('id',$id)->update($data)){ $this->success('提交成功'); } $this->error('提交失败,请稍后重试'); } /** * @Title("维修订单") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("type",type="string",require=1,default="",desc="1:我是船老板2:我是维修工") * @Param("status",type="string",require=1,default="",desc="1:未报价2:已报价3:已匹配") */ public function repair(){ $data = $this->_vali([ 'type.require|in:1,2'=>'字段有误', 'status.require|in:1,2,3'=>'字段有误', ]); switch ($data['type']){ case 1: $list = DataUserRepair::mk() ->where('uuid',$this->uuid) ->where('status',$data['status']) ->where('is_del',1) ->paginate(); break; case 2: $status = $data['status']; $list = DataUserRepairOffer::mk() ->hasWhere('repair',function (Query $query){ $query->where('is_del',1); }) ->with(['repair'=>function($query){ $query->withoutField('is_del,update_at'); }]) ->where('offer_id',$this->uuid) ->where(function ($query) use ($status){ $repair_ids = DataUserRepairOffer::mk() ->where('offer_id',$this->uuid) ->where('price','>',0) ->group('repair_id') ->column('repair_id'); switch ($status){ case 1: $query->whereNotIn('repair_id',$repair_ids)->where('is_deal',0)->where('status',2); break; case 2: $query->whereIn('repair_id',$repair_ids)->where('is_deal',0)->where('status',2); break; case 3: $query->where('is_deal',1)->where('status',3); break; } }) ->field('data_user_repair_offer.id,repair_id,offer_id') ->order('id desc') ->group('repair_id') ->paginate(); $list = $list->toArray(); foreach ($list['data'] as &$v){ $in = DataUserRepairOffer::mk() ->where('repair_id',$v['repair_id']) ->where('offer_id',$v['offer_id']) ->order('id desc') ->limit(1) ->field('id,price')->find(); $v['price'] = $in->price; } break; } $this->success('成功',$list); } /** * @Title("维修订单删除(只有维修订单未报价和已报价可以删除)") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="type为1时:维修单ID type为2时报价记录ID") */ public function repairdel(){ $data = $this->_vali([ 'id.require'=>'id有误', ]); if (DataUserRepair::mk()->where('id',$data['id'])->where('uuid',$this->uuid)->update(['is_del'=>0])){ $this->success('成功'); } $this->error('失败'); } /** * @Title("维修订单详情页") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("type",type="string",require=1,default="",desc="1:我是船老板2:我是维修工") * @Param("id",type="string",require=1,default="",desc="type为1时:维修单ID type为2时报价记录ID") */ public function repairdetail(){ $data = $this->_vali([ 'type.require|in:1,2'=>'字段有误', 'id.require'=>'id有误', ]); //$this->uuid = 69; switch ($data['type']){ case 1: $info = DataUserRepair::mk() ->where('uuid',$this->uuid) ->where('is_del',1) ->where('id',$data['id']) ->with(['user'=>function($query){ $query->field('id,nickname,headimg,phone'); },'offer'=>function($query){ $query->field('id,repair_id,offer_id,price,imgs')->group('offer_id') ->with(['user'=>function($query){ $query->field('id,nickname,headimg,phone'); }]); },'success'=>function($query){ $query->field('id,nickname,headimg,phone'); }]) ->find()->toArray(); foreach ($info['offer'] as &$v){ $in = DataUserRepairOffer::mk() ->where('repair_id',$data['id']) ->where('offer_id',$v['offer_id']) ->order('id desc') ->limit(1) ->field('id,price')->find(); $v['id'] = $in->id; $v['price'] = $in->price; } break; case 2: $info = DataUserRepairOffer::mk() ->where('id',$data['id']) ->with(['user'=>function($query){ $query->field('id,nickname,headimg,phone'); },'repair'=>function($query){ $query->with(['user'=>function($query){ $query->field('id,nickname,headimg,phone'); }]); }]) ->find()->toArray(); $in = DataUserRepairOffer::mk() ->where('repair_id',$info['repair_id']) ->where('offer_id',$info['offer_id']) ->order('id desc') ->limit(1) ->field('id,price')->find(); $info['price'] = $in['price']; break; } $this->success('成功',$info); } /** * @Title("维修订单确认匹配") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="维修单ID") * @Param("offer_id",type="string",require=1,default="",desc="匹配的记录ID") */ public function repairoffer(){ $data = $this->_vali([ 'id.require'=>'id有误', 'offer_id.require'=>'offer_id有误', ]); DataUserRepair::mk()->where('id',$data['id'])->value('status') == 3 ? $this->error('订单已经匹配成功') : ''; $offer = DataUserRepairOffer::mk()->where('id',$data['offer_id'])->find(); if (DataUserRepair::mk()->where('id',$data['id'])->update(['status'=>3,'success_uuid'=>$offer->offer_id,'success_price'=>$offer->price,'success_at'=>date('Y-m-d H:i:s')]) && DataUserRepairOffer::mk()->where('id',$data['offer_id'])->update(['is_deal'=>1,'deal_at'=>date('Y-m-d H:i:s')])){ $this->success('成功'); } $this->error('失败'); } /** * @Title("维修订单详情页用户报价列表点击查看详情") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="维修单ID") * @Param("offer_id",type="string",require=1,default="",desc="匹配的offer_id") */ public function userofferinfo(){ $data = $this->_vali([ 'id.require'=>'id有误', 'offer_id.require'=>'offer_id有误', ]); // $this->uuid = 69; $offer_id = $data['offer_id']; $list = DataUserRepairOffer::mk() ->where('repair_id',$data['id']) ->where(function ($query) use ($offer_id){ $query->where('offer_id',$offer_id); }) ->field('id,price') ->select(); $imgs = array_filter(explode(',',DataUserRepairOffer::mk()->where('repair_id',$data['id']) ->where('offer_id',$offer_id) ->order('id desc') ->limit(1) ->value('imgs'))); $messagelist = DataUserLeaveMessage::mk() ->where('type',1) ->whereRaw("(uuid=$this->uuid and uuid2=$offer_id) or (uuid2=$this->uuid and uuid=$offer_id)") ->where('link_id',$data['id']) ->with(['user'=>function($query){ $query->field('id,nickname,headimg'); }]) ->field('id,uuid,uuid2,content,create_at') ->select(); $this->success('成功',compact('list','imgs','messagelist')); } /** * @Title("维修订单留言") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="维修单ID") * @Param("offer_id",type="string",require=1,default="",desc="匹配的记录ID") * @Param("content",type="string",require=1,default="",desc="内容") */ public function subleavemessage(){ $data = $this->_vali([ 'id.require'=>'id有误', 'offer_id.require'=>'offer_id有误', 'content.require'=>'内容必须', ]); $offer = DataUserRepairOffer::mk()->where('id',$data['offer_id'])->findOrEmpty(); $array = [ 'uuid'=>$this->uuid, 'uuid2'=>$offer->offer_id, 'content'=>$data['content'], 'type'=>1, 'link_id'=>$data['id'], ]; if (DataUserLeaveMessage::mk()->insert($array)){ $this->success('成功'); } $this->error('失败'); } /** * @Title("维修订单维修工回复留言") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="维修单ID") * @Param("content",type="string",require=1,default="",desc="内容") */ public function subofferleavemessage(){ $data = $this->_vali([ 'id.require'=>'id有误', 'content.require'=>'内容必须', ]); $repair = DataUserRepair::mk()->where('id',$data['id'])->findOrEmpty(); $array = [ 'uuid'=>$this->uuid, 'uuid2'=>$repair->uuid, 'content'=>$data['content'], 'type'=>1, 'link_id'=>$data['id'], ]; if (DataUserLeaveMessage::mk()->insert($array)){ $this->success('成功'); } $this->error('失败'); } /** * @Title("维修订单维修工查看留言列表") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="维修单ID") */ public function suboffermessagelist(){ $data = $this->_vali([ 'id.require'=>'id有误', ]); // $this->uuid = 54; $uid = DataUserRepair::mk()->where('id',$data['id'])->value('uuid'); if (!$uid) $this->error('订单未找到'); $messagelist = DataUserLeaveMessage::mk() ->where('type',1) ->where('link_id',$data['id']) ->whereRaw("(uuid=$this->uuid and uuid2=$uid) or uuid2=$this->uuid and uuid=$uid") // ->whereRaw("uuid=$this->uuid or uuid2=$this->uuid") ->with(['user'=>function($query){ $query->field('id,nickname,headimg'); }]) ->field('id,uuid,uuid2,content,create_at') ->select(); $this->success('成功',$messagelist); } /** * @Title("消息未读数量") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Returned("message_count",desc="后台消息未读数量") * @Returned("notice_count",desc="系统通知未读数量") */ public function messagenoread(){ $message = BaseUserMessage::mk()->where('type','message')->where('status',1) ->where('deleted',0)->column('id'); $notice = BaseUserMessage::mk()->where('type','notice')->where('status',1) ->where('deleted',0)->column('id'); $message_read_count = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->whereIn('message_id',$message)->count(); $notice_read_count = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->whereIn('message_id',$notice)->count(); $array = [ 'message_count'=>count($message)-$message_read_count, 'notice_count'=>count($notice)-$notice_read_count ]; $this->success('成功',$array); } /** * @Title("消息") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("type",type="string",require=1,default="",desc="message:后台消息 notice:系统通知") * @Returned("is_read",desc="1:已读 0:未读") */ public function messagelist(){ $data = $this->_vali([ 'type.require'=>'type有误', ]); $type = $data['type']; $messagelist = BaseUserMessage::mk() ->where('type',$data['type']) ->when($type,function ($query) use ($type){ if ($type=='notice'){ $query->where('uuid',$this->uuid); } }) ->where('status',1) ->where('deleted',0) ->withoutField('deleted,sort,num_read,status') ->order('id desc') ->paginate()->toArray(); foreach ($messagelist['data'] as &$v){ $v['is_read'] = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->where('message_id',$v['id'])->count() ? 1 : 0; } $this->success('成功',$messagelist); } /** * @Title("点击消息") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * @Param("id",type="string",require=1,default="",desc="消息ID") */ public function readmessage(){ $data = $this->_vali([ 'id.require'=>'id有误', ]); $info = BaseUserMessage::mk()->where('id',$data['id'])->findOrEmpty(); BaseUserMessageRead::mk()->where('uuid',$this->uuid)->where('message_id',$data['id'])->count() ? : BaseUserMessageRead::mk()->insert(['message_id'=>$data['id'],'uuid'=>$this->uuid]); $this->success('成功',$info); } /** * @Title("获取安卓版本") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * * @Returned("version",desc="当前版本") * @Returned("name",desc="版本名") * @Returned("title",desc="更新标题") * @Returned("isCompel",desc="1:强制更新 0:不强制更新") * @Returned("content",desc="更新内容") * @Returned("download_url",desc="下载地址")' * * @Returned("version2",desc="商家端当前版本") * @Returned("name2",desc="商家端版本名") * @Returned("title2",desc="商家端更新标题") * @Returned("isCompel2",desc="商家端1:强制更新 0:不强制更新") * @Returned("content2",desc="商家端更新内容") * @Returned("download_url2",desc="商家端下载地址") */ public function getandroidversion(){ $info= [ 'version'=>(int)sysconf('android.version'), 'name'=>sysconf('android.name'), 'title'=>sysconf('android.title'), 'isCompel'=>(int)sysconf('android.isCompel'), 'content'=>sysconf('android.content'), 'download_url'=>sysconf('android.download_url'), 'version2'=>(int)sysconf('android.version2'), 'name2'=>sysconf('android.name2'), 'title2'=>sysconf('android.title2'), 'isCompel2'=>(int)sysconf('android.isCompel2'), 'content2'=>sysconf('android.content2'), 'download_url2'=>sysconf('android.download_url2'), ]; $this->success('成功',$info); } /** * @Title("获取ios版本") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * * @Returned("version",desc="当前版本") * @Returned("name",desc="版本名") * @Returned("title",desc="更新标题") * @Returned("isCompel",desc="1:强制更新 0:不强制更新") * @Returned("content",desc="更新内容") */ public function getiosversion(){ $info= [ 'version'=>(int)sysconf('ios.version'), 'name'=>sysconf('ios.name'), 'title'=>sysconf('ios.title'), 'isCompel'=>(int)sysconf('ios.isCompel'), 'content'=>sysconf('ios.content'), // 'download_url'=>sysconf('android.download_url'), ]; $this->success('成功',$info); } /** * @Title("获取商家入驻规则、船厂入驻规则") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * * @Returned("business_join_rule",desc="商家入驻规则") * @Returned("shipyard_join_rule",desc="船厂入驻规则") */ public function getrule(){ $info= [ 'business_join_rule'=>htmlspecialchars_decode(sysconf('business.business_join_rule')), 'shipyard_join_rule'=>htmlspecialchars_decode(sysconf('shipyard.shipyard_join_rule')), ]; $this->success('成功',$info); } /** * @Title("账号注销") * @Method("post") * @Header("api-name",type="string",require=1,default="",desc="访问类型") * @Header("api-token",type="string",require=1,default="",desc="token") * */ public function cancellation(){ if (DataUser::mk()->where('id',$this->uuid)->update(['status'=>0])){ $this->success('注销成功'); } $this->error('注销失败'); } public function ccc(){ // $dir = dirname(realpath(dirname($_SERVER['SCRIPT_FILENAME']))) . '/public/'; // $templateProcessor = new TemplateProcessor($dir.'/wxdd.docx'); // $templateProcessor->setValue('order_no','1234'); // $templateProcessor->setValue('date','2023-02-20 15:05:50'); // $templateProcessor->setValue('fbz','张三'); // $templateProcessor->setValue('jdf','李四'); // $templateProcessor->setValue('fbzphone','15800000000'); // $templateProcessor->setValue('jdfphone','15800000001'); // $templateProcessor->setValue('address','藕粉色大后方胡搜凤凰山佛山房'); // $templateProcessor->setValue('time','2023-02-20 15:10:00'); // $templateProcessor->setValue('desc','维修单维修单'); // $templateProcessor->setValue('price','100'); // $templateProcessor->saveAs($dir."b.docx"); $dir = dirname(realpath(dirname($_SERVER['SCRIPT_FILENAME']))) . '/public/'; $templateProcessor = new TemplateProcessor($dir.'/cgdd.docx'); $templateProcessor->setValue('order_no','1234'); $templateProcessor->setValue('date','2023-02-20 15:05:50'); $templateProcessor->setValue('fbz','张三'); $templateProcessor->setValue('jdf','李四'); $templateProcessor->setValue('fbzphone','15800000000'); $templateProcessor->setValue('jdfphone','15800000001'); $templateProcessor->setValue('address','藕粉色大后方胡搜凤凰山佛山房'); $templateProcessor->setValue('time','2023-02-20 15:10:00'); $templateProcessor->setValue('desc','维修单维修单'); $templateProcessor->setValue('price','100'); $templateProcessor->saveAs($dir."b.docx"); } }