12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718 |
- <?php
- namespace app\data\controller\api\auth;
- use app\data\controller\api\Auth;
- use app\data\controller\api\Data;
- use app\data\model\BaseUserMessage;
- use app\data\model\BaseUserMessageRead;
- use app\data\model\BaseUserPayment;
- use app\data\model\BaseUserUpgrade;
- use app\data\model\DataBestKnowledge;
- use app\data\model\DataCollectionLog;
- use app\data\model\DataFeedback;
- use app\data\model\DataMaintenance;
- use app\data\model\DataMerchants;
- use app\data\model\DataPoolTalent;
- use app\data\model\DataPoolTalentChild;
- use app\data\model\DataShipyard;
- use app\data\model\DataTeachingKnowledge;
- use app\data\model\DataUser;
- use app\data\model\DataUserAcceptance;
- use app\data\model\DataUserApplyJobInfo;
- use app\data\model\DataUserApplyJobInfoChild;
- use app\data\model\DataUserBankCard;
- use app\data\model\DataUserLeaveMessage;
- use app\data\model\DataUserMoneyLog;
- use app\data\model\DataUserPurchaseAcceptance;
- use app\data\model\DataUserRepair;
- use app\data\model\DataUserRepairOffer;
- use app\data\model\DataUserVipOrder;
- use app\data\model\DataUserWithdraw;
- use app\data\model\DataZhicheng;
- use app\data\model\ShopCoordination;
- use app\data\model\ShopFavourite;
- use app\data\model\ShopOcean;
- use app\data\model\ShopProduction;
- use app\data\model\ShopPurchase;
- use app\data\service\payment\WechatPaymentService;
- use app\data\service\PaymentService;
- use app\data\service\UserAdminService;
- use app\data\service\UserUpgradeService;
- use PhpOffice\PhpWord\PhpWord;
- use PhpOffice\PhpWord\TemplateProcessor;
- use think\admin\Storage;
- use think\db\Query;
- use think\exception\HttpResponseException;
- use think\admin\Controller;
- use hg\apidoc\annotation\Title;
- use hg\apidoc\annotation\Method;
- use hg\apidoc\annotation\Param;
- use hg\apidoc\annotation\Header;
- use hg\apidoc\annotation\Returned;
- use think\facade\Db;
- use think\facade\Validate;
- use WePay\Order;
- use app\api\controller\Certification;
- /**
- * @Title("个人中心")
- */
- class Center extends Auth
- {
- protected $noNeedLogin=['upload','image','uploadmore','messagelist'];
- /**
- * @Title("获取用户资料")
- * @Method("post")
- * @Header("api-name",type="string",require=1,default="",desc="访问类型")
- * @Header("api-token",type="string",require=1,default="",desc="token")
- * @Returned("token.token",desc="token")
- * @Returned("pooltalent",desc="提交的人才库信息,为空则未提交")
- * @Returned("pooltalent.audit",desc="人才库审核状态1:待审核 2:审核通过 3:审核不通过")
- * @Returned("pooltalent.why",desc="人才库审核不通过原因")
- * @Returned("maintenance",desc="提交的维修工申请,为空则未提交")
- * @Returned("maintenance.audit",desc="维修工申请审核状态1:待审核 2:审核通过 3:审核不通过")
- * @Returned("maintenance.why",desc="维修工申请审核不通过原因")
- * @Returned("shipyard",desc="提交的入驻船厂申请,为空则未提交")
- * @Returned("shipyard.audit",desc="入驻船厂申请审核状态1:待审核 2:审核通过 3:审核不通过")
- * @Returned("shipyard.why",desc="入驻船厂申请审核不通过原因")
- * @Returned("merchants",desc="提交的入驻商家申请,为空则未提交")
- * @Returned("merchants.audit",desc="入驻商家申请审核状态1:待审核 2:审核通过 3:审核不通过")
- * @Returned("merchants.why",desc="入驻商家申请审核不通过原因")
- * @Returned("collection_count",desc="收藏数量")
- */
- public function get()
- {
- $user = $this->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')])){
- $url = setword(1,$data['id']);
- DataUserRepair::mk()->where('id',$data['id'])->update(['down_word'=>$url]);
- $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(){
- // $list = DataUserRepair::mk()->where('status',3)->select();
- // foreach ($list as &$v){
- // $url = setword(1,$v['id']);
- // DataUserRepair::mk()->where('id',$v['id'])->update(['down_word'=>$url]);
- // }
- // die();
- echo setword(4,5);
- die;
- // $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','2312312313');
- $templateProcessor->cloneRow('id',3);
- $templateProcessor->setValue('id#1', '1');
- $templateProcessor->setValue('bh#1', '1');
- $templateProcessor->setValue('name#1', '名称');
- $templateProcessor->setValue('gg#1', '规格');
- $templateProcessor->setValue('num#1', '10');
- $templateProcessor->setValue('price#1', '10');
- $templateProcessor->setValue('allprice#1', '20');
- $templateProcessor->setValue('id#2', '1');
- $templateProcessor->setValue('bh#2', '1');
- $templateProcessor->setValue('name#2', '名称');
- $templateProcessor->setValue('gg#2', '规格');
- $templateProcessor->setValue('num#2', '10');
- $templateProcessor->setValue('price#2', '10');
- $templateProcessor->setValue('allprice#2', '20');
- $templateProcessor->setValue('id#3', '1');
- $templateProcessor->setValue('bh#3', '1');
- $templateProcessor->setValue('name#3', '名称');
- $templateProcessor->setValue('gg#3', '规格');
- $templateProcessor->setValue('num#3', '10');
- $templateProcessor->setValue('price#3', '10');
- $templateProcessor->setValue('allprice#3', '20');
- $templateProcessor->saveAs($dir."c.docx");
- }
- }
|