Center.php 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718
  1. <?php
  2. namespace app\data\controller\api\auth;
  3. use app\data\controller\api\Auth;
  4. use app\data\controller\api\Data;
  5. use app\data\model\BaseUserMessage;
  6. use app\data\model\BaseUserMessageRead;
  7. use app\data\model\BaseUserPayment;
  8. use app\data\model\BaseUserUpgrade;
  9. use app\data\model\DataBestKnowledge;
  10. use app\data\model\DataCollectionLog;
  11. use app\data\model\DataFeedback;
  12. use app\data\model\DataMaintenance;
  13. use app\data\model\DataMerchants;
  14. use app\data\model\DataPoolTalent;
  15. use app\data\model\DataPoolTalentChild;
  16. use app\data\model\DataShipyard;
  17. use app\data\model\DataTeachingKnowledge;
  18. use app\data\model\DataUser;
  19. use app\data\model\DataUserAcceptance;
  20. use app\data\model\DataUserApplyJobInfo;
  21. use app\data\model\DataUserApplyJobInfoChild;
  22. use app\data\model\DataUserBankCard;
  23. use app\data\model\DataUserLeaveMessage;
  24. use app\data\model\DataUserMoneyLog;
  25. use app\data\model\DataUserPurchaseAcceptance;
  26. use app\data\model\DataUserRepair;
  27. use app\data\model\DataUserRepairOffer;
  28. use app\data\model\DataUserVipOrder;
  29. use app\data\model\DataUserWithdraw;
  30. use app\data\model\DataZhicheng;
  31. use app\data\model\ShopCoordination;
  32. use app\data\model\ShopFavourite;
  33. use app\data\model\ShopOcean;
  34. use app\data\model\ShopProduction;
  35. use app\data\model\ShopPurchase;
  36. use app\data\service\payment\WechatPaymentService;
  37. use app\data\service\PaymentService;
  38. use app\data\service\UserAdminService;
  39. use app\data\service\UserUpgradeService;
  40. use PhpOffice\PhpWord\PhpWord;
  41. use PhpOffice\PhpWord\TemplateProcessor;
  42. use think\admin\Storage;
  43. use think\db\Query;
  44. use think\exception\HttpResponseException;
  45. use think\admin\Controller;
  46. use hg\apidoc\annotation\Title;
  47. use hg\apidoc\annotation\Method;
  48. use hg\apidoc\annotation\Param;
  49. use hg\apidoc\annotation\Header;
  50. use hg\apidoc\annotation\Returned;
  51. use think\facade\Db;
  52. use think\facade\Validate;
  53. use WePay\Order;
  54. use app\api\controller\Certification;
  55. /**
  56. * @Title("个人中心")
  57. */
  58. class Center extends Auth
  59. {
  60. protected $noNeedLogin=['upload','image','uploadmore','messagelist'];
  61. /**
  62. * @Title("获取用户资料")
  63. * @Method("post")
  64. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  65. * @Header("api-token",type="string",require=1,default="",desc="token")
  66. * @Returned("token.token",desc="token")
  67. * @Returned("pooltalent",desc="提交的人才库信息,为空则未提交")
  68. * @Returned("pooltalent.audit",desc="人才库审核状态1:待审核 2:审核通过 3:审核不通过")
  69. * @Returned("pooltalent.why",desc="人才库审核不通过原因")
  70. * @Returned("maintenance",desc="提交的维修工申请,为空则未提交")
  71. * @Returned("maintenance.audit",desc="维修工申请审核状态1:待审核 2:审核通过 3:审核不通过")
  72. * @Returned("maintenance.why",desc="维修工申请审核不通过原因")
  73. * @Returned("shipyard",desc="提交的入驻船厂申请,为空则未提交")
  74. * @Returned("shipyard.audit",desc="入驻船厂申请审核状态1:待审核 2:审核通过 3:审核不通过")
  75. * @Returned("shipyard.why",desc="入驻船厂申请审核不通过原因")
  76. * @Returned("merchants",desc="提交的入驻商家申请,为空则未提交")
  77. * @Returned("merchants.audit",desc="入驻商家申请审核状态1:待审核 2:审核通过 3:审核不通过")
  78. * @Returned("merchants.why",desc="入驻商家申请审核不通过原因")
  79. * @Returned("collection_count",desc="收藏数量")
  80. */
  81. public function get()
  82. {
  83. $user = $this->getUser();
  84. $user['collection_count'] = DataCollectionLog::mk()->where('uuid',$this->uuid)->where('cate',1)->whereNotIn('type',[3,4])->count();
  85. $this->success('获取用户资料', $user);
  86. }
  87. /**
  88. * @Title("平台规则")
  89. * @Method("post")
  90. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  91. * @Header("api-token",type="string",require=1,default="",desc="token")
  92. *
  93. * @Returned("platform_rules",desc="平台规则")
  94. */
  95. public function getplatformrules(){
  96. $info= [
  97. 'platform_rules'=>htmlspecialchars_decode(sysconf('platform.platform_rules')),
  98. ];
  99. $this->success('成功',$info);
  100. }
  101. /**
  102. * @Title("Base64图片上传")
  103. * @Method("post")
  104. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  105. * @Header("api-token",type="string",require=0,default="",desc="token")
  106. * @Returned("url",desc="图片地址")
  107. */
  108. public function image()
  109. {
  110. try {
  111. $data = $this->_vali(['base64.require' => '图片内容不为空!']);
  112. if (preg_match($preg = '|^data:image/(.*?);base64,|i', $data['base64'])) {
  113. [$ext, $img] = explode('|||', preg_replace($preg, '$1|||', $data['base64']));
  114. if (empty($ext) || !in_array(strtolower($ext), ['png', 'jpg', 'jpeg'])) {
  115. $this->error('图片格式异常!');
  116. }
  117. $name = Storage::name($img, $ext, 'image/');
  118. $info = Storage::instance()->set($name, base64_decode($img));
  119. $this->success('图片上传成功!', ['url' => $info['url']]);
  120. } else {
  121. $this->error('解析内容失败!');
  122. }
  123. } catch (HttpResponseException $exception) {
  124. throw $exception;
  125. } catch (\Exception $exception) {
  126. trace_file($exception);
  127. $this->error($exception->getMessage());
  128. }
  129. }
  130. /**
  131. * @Title("二进制图片、文件上传")
  132. * @Method("post")
  133. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  134. * @Header("api-token",type="string",require=0,default="",desc="token")
  135. * @Param("file",type="file",require=1,default="",desc="文件")
  136. * @Returned("url",desc="图片地址")
  137. */
  138. public function upload()
  139. {
  140. ini_set ("memory_limit","-1");
  141. $file = $this->request->file('file');
  142. if (empty($file)) $this->error('文件上传异常!');
  143. $extension = strtolower($file->getOriginalExtension());
  144. if (in_array($extension, ['php', 'sh'])) $this->error('禁止上传此类文件!');
  145. $bina = file_get_contents($file->getRealPath());
  146. $name = Storage::name($file->getPathname(), $extension, '', 'md5_file');
  147. $info = Storage::instance()->set($name, $bina, false, $file->getOriginalName());
  148. if (is_array($info) && isset($info['url'])) {
  149. $this->success('文件上传成功!', $info);
  150. } else {
  151. $this->error('文件上传失败!');
  152. }
  153. }
  154. /**
  155. * @Title("二进制图片、文件上传多个")
  156. * @Method("post")
  157. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  158. * @Header("api-token",type="string",require=0,default="",desc="token")
  159. * @Param("file[]",type="file",require=1,default="",desc="文件")
  160. * @Returned("url",desc="图片地址")
  161. */
  162. public function uploadmore()
  163. {
  164. ini_set ("memory_limit","-1");
  165. $file = $this->request->file('file');
  166. if (empty($file)) $this->error('文件上传异常!');
  167. $array = [];
  168. foreach ($file as $file){
  169. $extension = strtolower($file->getOriginalExtension());
  170. if (in_array($extension, ['php', 'sh'])) $this->error('禁止上传此类文件!');
  171. $bina = file_get_contents($file->getRealPath());
  172. $name = Storage::name($file->getPathname(), $extension, '', 'md5_file');
  173. $info = Storage::instance()->set($name, $bina, false, $file->getOriginalName());
  174. array_push($array,$info);
  175. }
  176. $this->success('文件上传成功!', $array);
  177. }
  178. /**
  179. * @Title("更新用户资料")
  180. * @Method("post")
  181. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  182. * @Header("api-token",type="string",require=1,default="",desc="token")
  183. * @Param("headimg",type="string",require=0,default="",desc="头像")
  184. * @Param("nickname",type="string",require=0,default="",desc="昵称")
  185. * @Param("email",type="string",require=0,default="",desc="邮箱")
  186. * @Param("base_sex",type="string",require=0,default="",desc="性别")
  187. */
  188. public function set()
  189. {
  190. $data = $this->_vali([
  191. 'headimg.default' => '',
  192. 'nickname.default' => '',
  193. 'email.default' => '',
  194. 'base_sex.default' => '',
  195. ]);
  196. foreach ($data as $key => $vo) if ($vo === '') unset($data[$key]);
  197. if (empty($data)) $this->error('没有修改的数据!');
  198. if (DataUser::mk()->where(['id' => $this->uuid])->update($data) !== false) {
  199. $this->success('更新资料成功!', $this->getUser());
  200. } else {
  201. $this->error('更新资料失败!');
  202. }
  203. }
  204. /**
  205. * @Title("修改密码")
  206. * @Method("post")
  207. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  208. * @Header("api-token",type="string",require=1,default="",desc="token")
  209. * @Param("password",type="string",require=0,default="",desc="原密码")
  210. * @Param("newpassword",type="string",require=0,default="",desc="新密码")
  211. */
  212. public function uppass()
  213. {
  214. $data = $this->_vali([
  215. 'password.require'=>'原密码必须',
  216. 'newpassword.require'=>'新密码必须'
  217. ]);
  218. if ($data['password']==$data['newpassword']) $this->error('原密码与新密码一样');
  219. $pass = DataUser::mk()->where('id',$this->uuid)->value('password');
  220. if (md5($data['password'])!=$pass) $this->error('原密码验证错误');
  221. if (DataUser::mk()->where(['id' => $this->uuid])->update(['password'=>md5($data['newpassword'])]) !== false) {
  222. $this->success('更新密码成功!', $this->getUser());
  223. } else {
  224. $this->error('更新密码失败!');
  225. }
  226. }
  227. /**
  228. * @Title("获取开通vip配置信息")
  229. * @Method("post")
  230. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  231. * @Header("api-token",type="string",require=1,default="",desc="token")
  232. *
  233. * @Returned("price",desc="价格")
  234. * @Returned("user_vip_des",desc="会员权益说明")
  235. * @Returned("user_vip_agreement",desc="会员服务协议")
  236. */
  237. public function getvipinfo(){
  238. $info= [
  239. 'price'=>sysconf('user_vip.price'),
  240. 'user_vip_des'=>htmlspecialchars_decode(sysconf('user_vip.user_vip_des')),
  241. 'user_vip_agreement'=>htmlspecialchars_decode(sysconf('user_vip.user_vip_agreement')),
  242. ];
  243. $this->success('成功',$info);
  244. }
  245. /**
  246. * @Title("获取支付方式")
  247. * @Method("post")
  248. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  249. * @Header("api-token",type="string",require=1,default="",desc="token")
  250. *
  251. * @Param("type",type="string",require=1,default="",desc="1:开通会员vip 2:商城、充值")
  252. * @Param("from",type="string",require=1,default="",desc="1:微信小程序 2:APP")
  253. */
  254. public function channel()
  255. {
  256. $data = $this->_vali([
  257. 'type.require|in:1,2'=>'type有误',
  258. 'from.require|in:1,2'=>'来源有误'
  259. ]);
  260. $type = $data['type'];
  261. $from = $data['from'];
  262. // 读取支付通道配置
  263. $query = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0])
  264. ->when($type,function ($query) use ($type){
  265. if ($type==2){
  266. $query->where('type','<>','balance');
  267. }
  268. })->where(function ($query) use ($from){
  269. if ($from==1){
  270. $query->whereNotIn('type',['wechat_app','alipay_app']);
  271. }else{
  272. $query->where('type','<>','wechat_xcx');
  273. }
  274. });
  275. //$query->whereIn('code', str2arr($payments))->whereIn('type', PaymentService::getTypeApi($this->type));
  276. $result = $query->order('sort desc,id desc')->column('type,code,name,cover,content,remark', 'code');
  277. foreach ($result as &$vo) $vo['content'] = ['voucher_qrcode' => json_decode($vo['content'])->voucher_qrcode ?? ''];
  278. $this->success('获取支付参数数据', array_values($result));
  279. }
  280. /**
  281. * @Title("开通会员")
  282. * @Method("post")
  283. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  284. * @Header("api-token",type="string",require=1,default="",desc="token")
  285. * @Param("pay_code",type="string",require=1,default="",desc="支付方式code")
  286. * @Param("difference_pay_code",type="string",require=0,default="",desc="余额支付时,差价支付方式code")
  287. *
  288. */
  289. public function openvip(){
  290. $user = $this->getUser();
  291. $data = $this->_vali([
  292. 'pay_code.require'=>'支付code有误',
  293. 'difference_pay_code.default'=>''
  294. ]);
  295. $code = $data['pay_code'];
  296. $difference_pay_code = $data['difference_pay_code'];
  297. $pay_type = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0,'code'=>$code])->value('type') ? : $this->error('支付找不到');
  298. $all_price = sysconf('user_vip.price');
  299. $order_no = setorderno($this->uuid);
  300. $insert = [
  301. 'uuid'=>$this->uuid,
  302. 'order_no'=>$order_no,
  303. 'all_price'=>$all_price,
  304. 'pay_type'=>$pay_type
  305. ];
  306. $error = 1;
  307. Db::startTrans();
  308. $retrun_data = [];
  309. try {
  310. if ($pay_type=='balance'){
  311. if ($user['money']<$all_price){
  312. if (empty($difference_pay_code) || !isset($difference_pay_code)){
  313. $error = 0;
  314. $errorinfo = '余额不足';
  315. }else{
  316. $difference_pay_type = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0,'code'=>$difference_pay_code])->value('type');
  317. if (!$difference_pay_type){
  318. $error = 0;
  319. $errorinfo = '差价支付找不到';
  320. }else{
  321. $all_price = bcsub($all_price,$user['money'],2);
  322. $insert['yue_price'] = $user['money'];
  323. $insert['difference_money'] = $all_price;
  324. $insert['difference_pay_type'] = $difference_pay_type;
  325. $code = $difference_pay_code;
  326. $pay_type = $difference_pay_type;
  327. }
  328. }
  329. }
  330. }
  331. $order_id = DataUserVipOrder::mk()->insertGetId($insert);
  332. if (stripos($pay_type, 'alipay_') === 0) {
  333. $notify_name = 'opvipzfb';
  334. } elseif (stripos($pay_type, 'wechat_') === 0) {
  335. $notify_name = 'opvipwx';
  336. } else{
  337. $notify_name = 'opvip';
  338. }
  339. $notify_url = sysuri("@data/api.notify/{$notify_name}/scene/order/param/{$code}", [], false, true);
  340. $parm = ['uuid'=>$this->uuid,'order_id'=>$order_id];
  341. $pay =PaymentService::instance($code)->create($user['openid1'],$order_no,$all_price,'开通vip','开通vip','','',$notify_url,$parm);
  342. $retrun_data['order_no'] = $order_no;
  343. $pay['packages'] = isset($pay['package']) ? $pay['package'] : '';
  344. $retrun_data['pay'] = $pay;
  345. $retrun_data['success'] = isset($pay['result']) && $pay['result']=='success' ? 1 : 0;
  346. Db::commit();
  347. } catch (\Exception $e) {
  348. dump($e);
  349. // 回滚事务
  350. Db::rollback();
  351. $error = 0;
  352. $errorinfo = '未知错误';
  353. }
  354. if ($error){
  355. $this->success('成功',$retrun_data);
  356. }
  357. $this->error($errorinfo);
  358. }
  359. /**
  360. * @Title("人才库职称列表")
  361. * @Method("post")
  362. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  363. * @Header("api-token",type="string",require=1,default="",desc="token")
  364. */
  365. public function zclist()
  366. {
  367. $list = DataZhicheng::Show()->select();
  368. $this->success('成功',$list);
  369. }
  370. /**
  371. * @Title("加入人才库/编辑人才库")
  372. * @Method("post")
  373. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  374. * @Header("api-token",type="string",require=1,default="",desc="token")
  375. * @Param("name",type="string",require=1,default="",desc="姓名")
  376. * @Param("sex",type="string",require=1,default="",desc="性别")
  377. * @Param("age",type="string",require=1,default="",desc="年龄")
  378. * @Param("jg",type="string",require=1,default="",desc="籍贯")
  379. * @Param("phone",type="string",require=1,default="",desc="手机号")
  380. * @Param("email",type="string",require=1,default="",desc="邮箱")
  381. * @Param("province",type="string",require=1,default="",desc="省")
  382. * @Param("city",type="string",require=1,default="",desc="市")
  383. * @Param("area",type="string",require=1,default="",desc="区/镇")
  384. * @Param("address",type="string",require=1,default="",desc="详细地址")
  385. * @Param("graduate_school",type="string",require=1,default="",desc="毕业院校")
  386. * @Param("xl",type="string",require=1,default="",desc="学历")
  387. * @Param("major",type="string",require=1,default="",desc="专业")
  388. * @Param("working_life",type="string",require=1,default="",desc="工作年限")
  389. * @Param("tc",type="string",require=1,default="",desc="特长")
  390. * @Param("jn",type="string",require=1,default="",desc="技能")
  391. * @Param("zc_id",type="string",require=1,default="",desc="职称ID")
  392. * @Param("zz_imgs",type="string",require=1,default="",desc="资质证书,多个以逗号隔开")
  393. * @Param("pxjl",type="string",require=1,default="",desc="培训经历")
  394. * @Param("id",type="string",require=0,default="",desc="审核失败,修改,则必传之前提交的ID")
  395. */
  396. public function adduppooltalent()
  397. {
  398. $data = $this->_vali([
  399. 'uuid.default'=>$this->uuid,
  400. 'name.require'=>'姓名必须',
  401. 'sex.require'=>'性别必须',
  402. 'age.require|number|between:1,120'=>'年龄必须,1-120',
  403. 'jg.require'=>'籍贯必须',
  404. 'phone.require'=>'手机号必须',
  405. 'email.require'=>'邮箱必须',
  406. 'province.require'=>'省必须',
  407. 'city.require'=>'市必须',
  408. 'area.require'=>'区/镇必须',
  409. 'address.require'=>'详细地址必须',
  410. 'graduate_school.require'=>'毕业院校必须',
  411. 'xl.require'=>'学历必须',
  412. 'working_life.require'=>'工作年限必须',
  413. 'major.require'=>'专业必须',
  414. 'tc.require'=>'特长必须',
  415. 'jn.require'=>'技能必须',
  416. 'zc_id.require|number'=>'职称必须',
  417. 'zz_imgs.require'=>'资质证书必须',
  418. 'pxjl.require'=>'培训经历必须',
  419. ],'post');
  420. $id = input('id');
  421. if (!Validate::regex($data['phone'], "^1\d{10}$")) {
  422. $this->error('手机号格式错误');
  423. }
  424. DataZhicheng::mk()->where('id',$data['zc_id'])->where('is_del',1)->count() ? : $this->error('职称不存在');
  425. empty($id) ? $id = DataPoolTalent::mk()->where('uuid',$this->uuid)->value('id') : $data['update_at']=date('Y-m-d H:i:s');
  426. DataPoolTalent::mk()->where('uuid',$this->uuid)->value('audit') == 3 ? $data['audit'] =1 : '';
  427. if (empty($id) ? DataPoolTalent::mk()->insert($data) : DataPoolTalent::mk()->where('id',$id)->update($data)){
  428. $this->success('提交成功');
  429. }
  430. $this->error('提交失败,请稍后重试');
  431. }
  432. /**
  433. * @Title("添加人才库工作经历/编辑人才库工作经历")
  434. * @Method("post")
  435. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  436. * @Header("api-token",type="string",require=1,default="",desc="token")
  437. * @Param("id",type="string",require=1,default="",desc="工作经历ID,编辑时穿")
  438. * @Param("content",type="json",require=0,default="",desc="工作经历json,(company_name:公司名称,position_name:职位名称,on_job_start:在职时间开始,on_job_end:在职时间结束,job_description:工作内容)")
  439. */
  440. public function adduppooltalentchild()
  441. {
  442. $data = $this->_vali([
  443. 'id.default'=>'',
  444. 'content.require'=>'工作经历必须',
  445. ]);
  446. $info_id = DataPoolTalent::mk()->where('uuid',$this->uuid)->value('id') ? : DataPoolTalent::mk()->insertGetId(['uuid'=>$this->uuid]);
  447. $child_id = $data['id'];
  448. $child_array = [
  449. 'info_id'=>$info_id,
  450. 'content'=>$data['content']
  451. ];
  452. !empty($child_id) ? $child_array['update_at'] = date('Y-m-d H:i:s') : '';
  453. if (!empty($child_id) ? DataPoolTalentChild::mk()->where('id',$child_id)->update($child_array) : DataPoolTalentChild::mk()->insert($child_array)){
  454. $this->success('成功');
  455. }
  456. $this->error('失败');
  457. }
  458. /**
  459. * @Title("人才库工作经历删除")
  460. * @Method("post")
  461. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  462. * @Header("api-token",type="string",require=1,default="",desc="token")
  463. * @Param("id",type="string",require=1,default="",desc="ID")
  464. */
  465. public function delpooltalentchild(){
  466. $data = $this->_vali([
  467. 'id.require'=>'id必须',
  468. ]);
  469. if (DataPoolTalentChild::mk()->where('id',$data['id'])->delete()){
  470. $this->success('成功');
  471. }
  472. $this->error('失败');
  473. }
  474. /**
  475. * @Title("申请维修工/编辑维修工")
  476. * @Method("post")
  477. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  478. * @Header("api-token",type="string",require=1,default="",desc="token")
  479. * @Param("name",type="string",require=1,default="",desc="姓名")
  480. * @Param("id_card",type="string",require=1,default="",desc="身份证号")
  481. * @Param("email",type="string",require=1,default="",desc="邮箱")
  482. * @Param("province",type="string",require=1,default="",desc="省")
  483. * @Param("city",type="string",require=1,default="",desc="市")
  484. * @Param("area",type="string",require=1,default="",desc="区/镇")
  485. * @Param("address",type="string",require=1,default="",desc="详细地址")
  486. * @Param("id_card_img1",type="string",require=1,default="",desc="身份证人面照片")
  487. * @Param("id_card_img2",type="string",require=1,default="",desc="身份证国徽面照片")
  488. * @Param("business_img",type="string",require=1,default="",desc="营业执照图片")
  489. * @Param("authorization_img",type="string",require=0,default="",desc="厂家授权图片")
  490. * @Param("results",type="string",require=1,default="",desc="以往业绩")
  491. * @Param("id",type="string",require=0,default="",desc="审核失败,修改,则必传之前提交的ID")
  492. */
  493. public function addupmaintenance()
  494. {
  495. $data = $this->_vali([
  496. 'uuid.default'=>$this->uuid,
  497. 'name.require'=>'姓名必须',
  498. 'id_card.require'=>'身份证号必须',
  499. 'email.require'=>'邮箱必须',
  500. 'province.require'=>'省必须',
  501. 'city.require'=>'市必须',
  502. 'area.require'=>'区/镇必须',
  503. 'address.require'=>'详细地址必须',
  504. 'id_card_img1.require'=>'身份证人面照片必须',
  505. 'id_card_img2.require'=>'身份证国徽面照片必须',
  506. 'business_img.require'=>'营业执照图片必须',
  507. 'authorization_img.default'=>'',
  508. 'results.require'=>'以往业绩必须',
  509. ]);
  510. if (!check_idcard($data['id_card'])) $this->error('身份证号格式错误');
  511. $id = input('id');
  512. !empty($id) ? : (DataMaintenance::mk()->where('uuid',$this->uuid)->count() ? $this->error('已经提交过') : '' );
  513. empty($id) ? : $data['update_at']=date('Y-m-d H:i:s');
  514. DataMaintenance::mk()->where('uuid',$this->uuid)->value('audit') == 3 ? $data['audit'] =1 : '';
  515. if (empty($id) ? DataMaintenance::mk()->insert($data) : DataMaintenance::mk()->where('id',$id)->update($data)){
  516. $this->success('提交成功');
  517. }
  518. $this->error('提交失败,请稍后重试');
  519. }
  520. /**
  521. * @Title("申请船厂/编辑船厂")
  522. * @Method("post")
  523. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  524. * @Header("api-token",type="string",require=1,default="",desc="token")
  525. * @Param("name",type="string",require=1,default="",desc="船厂名称")
  526. * @Param("head_img",type="string",require=1,default="",desc="船厂头像")
  527. * @Param("province",type="string",require=1,default="",desc="省")
  528. * @Param("city",type="string",require=1,default="",desc="市")
  529. * @Param("area",type="string",require=1,default="",desc="区/镇")
  530. * @Param("address",type="string",require=1,default="",desc="详细地址")
  531. * @Param("contact_name",type="string",require=1,default="",desc="联系人")
  532. * @Param("contact_phone",type="string",require=1,default="",desc="联系电话")
  533. * @Param("intro",type="string",require=1,default="",desc="船厂简介")
  534. * @Param("longitude",type="string",require=1,default="",desc="经度")
  535. * @Param("latitude",type="string",require=1,default="",desc="维度")
  536. * @Param("environment_imgs",type="string",require=1,default="",desc="船厂环境,多个以英文逗号隔开")
  537. * @Param("product_intro",type="string",require=1,default="",desc="产品简介")
  538. * @Param("business_img",type="string",require=1,default="",desc="营业执照")
  539. * @Param("num_staff",type="string",require=1,default="",desc="员工人数")
  540. * @Param("id",type="string",require=0,default="",desc="审核失败,修改,则必传之前提交的ID")
  541. */
  542. public function addupshipyard()
  543. {
  544. $data = $this->_vali([
  545. 'uuid.default'=>$this->uuid,
  546. 'name.require'=>'船厂名称必须',
  547. 'longitude.require'=>'经纬度必须',
  548. 'longitude.float'=>'经纬度有误',
  549. 'latitude.require'=>'经纬度必须',
  550. 'latitude.float'=>'经纬度有误',
  551. 'head_img.require'=>'船厂头像必须',
  552. 'province.require'=>'省必须',
  553. 'city.require'=>'市必须',
  554. 'area.require'=>'区/镇必须',
  555. 'address.require'=>'详细地址必须',
  556. 'contact_name.require'=>'联系人必须',
  557. 'contact_phone.require'=>'联系电话必须',
  558. 'intro.require'=>'船厂简介必须',
  559. 'environment_imgs.require'=>'船厂环境必须',
  560. 'product_intro.require'=>'产品简介必须',
  561. 'business_img.require'=>'营业执照必须',
  562. 'num_staff.require'=>'人数必须',
  563. ]);
  564. $id = input('id');
  565. !empty($id) ? : (DataShipyard::mk()->where('uuid',$this->uuid)->count() ? $this->error('已经提交过') : '' );
  566. empty($id) ? : $data['update_at']=date('Y-m-d H:i:s');
  567. DataShipyard::mk()->where('uuid',$this->uuid)->value('audit') == 3 ? $data['audit'] =1 : '';
  568. if (empty($id) ? DataShipyard::mk()->insert($data) : DataShipyard::mk()->where('id',$id)->update($data)){
  569. $this->success('提交成功');
  570. }
  571. $this->error('提交失败,请稍后重试');
  572. }
  573. /**
  574. * @Title("申请商家/编辑商家")
  575. * @Method("post")
  576. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  577. * @Header("api-token",type="string",require=1,default="",desc="token")
  578. * @Param("name",type="string",require=1,default="",desc="商家名称")
  579. * @Param("head_img",type="string",require=1,default="",desc="商家头像")
  580. * @Param("province",type="string",require=1,default="",desc="省")
  581. * @Param("city",type="string",require=1,default="",desc="市")
  582. * @Param("area",type="string",require=1,default="",desc="区/镇")
  583. * @Param("address",type="string",require=1,default="",desc="详细地址")
  584. * @Param("longitude",type="string",require=1,default="",desc="经度")
  585. * @Param("latitude",type="string",require=1,default="",desc="纬度")
  586. * @Param("address",type="string",require=1,default="",desc="详细地址")
  587. * @Param("contact_name",type="string",require=1,default="",desc="联系人")
  588. * @Param("contact_phone",type="string",require=1,default="",desc="联系电话")
  589. * @Param("intro",type="string",require=1,default="",desc="商家简介")
  590. * @Param("imgs_videos",type="string",require=1,default="",desc="图片及视频,以英文逗号隔开")
  591. * @Param("business_img",type="string",require=1,default="",desc="营业执照")
  592. * @Param("id",type="string",require=0,default="",desc="审核失败,修改,则必传之前提交的ID")
  593. */
  594. public function addupmerchants()
  595. {
  596. $data = $this->_vali([
  597. 'uuid.default'=>$this->uuid,
  598. 'name.require'=>'商家名称必须',
  599. 'head_img.require'=>'商家头像必须',
  600. 'province.require'=>'省必须',
  601. 'city.require'=>'市必须',
  602. 'area.require'=>'区/镇必须',
  603. 'address.require'=>'详细地址必须',
  604. 'longitude.require'=>'经纬度必须',
  605. 'latitude.require'=>'经纬度必须',
  606. 'contact_name.require'=>'联系人必须',
  607. 'contact_phone.require'=>'联系电话必须',
  608. 'intro.require'=>'商家简介必须',
  609. 'imgs_videos.require'=>'图片及视频必须',
  610. 'business_img.require'=>'营业执照必须',
  611. ]);
  612. $id = input('id');
  613. !empty($id) ? : (DataMerchants::mk()->where('uuid',$this->uuid)->count() ? $this->error('已经提交过') : '' );
  614. empty($id) ? : $data['update_at']=date('Y-m-d H:i:s');
  615. DataMerchants::mk()->where('uuid',$this->uuid)->value('audit') == 3 ? $data['audit'] =1 : '';
  616. if (empty($id) ? DataMerchants::mk()->insert($data) : DataMerchants::mk()->where('id',$id)->update($data)){
  617. $this->success('提交成功');
  618. }
  619. $this->error('提交失败,请稍后重试');
  620. }
  621. /**
  622. * @Title("阿里云金融级实名认证初始化")
  623. * @Method("post")
  624. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  625. * @Header("api-token",type="string",require=1,default="",desc="token")
  626. * @Param("username",type="string",require=1,default="",desc="真实姓名")
  627. * @Param("id_card",type="string",require=1,default="",desc="身份证号")
  628. * @Param("MetaInfo",type="string",require=1,default="",desc="metainfo")
  629. * @Param("ReturnUrl",type="string",require=1,default="",desc="返回地址")
  630. */
  631. public function initFaceVerify(){
  632. $user = $this->getUser();
  633. //if ($user['is_auth']) $this->error('已实名认证');
  634. $data = $this->_vali([
  635. 'username.require'=>'真实姓名必须',
  636. 'id_card.require'=>'身份证号必须',
  637. 'MetaInfo.require'=>'metainfo必须',
  638. 'ReturnUrl.default'=>'2222'
  639. ]);
  640. if (!isCreditNo($data['id_card'])) $this->error('身份证号格式错误');
  641. DataUser::mk()->where('id_card',$data['id_card'])->count() ? $this->error('身份证号已认证过') : '';
  642. $res = main($data['username'],$data['id_card'],$data['MetaInfo'],$data['ReturnUrl']);
  643. if(!$res) $this->error('初始化错误');
  644. $result = json_decode(json_encode($res),true)['body'];
  645. $result['code'] != 200 ? $this->error($result['message']):$this->success('获取成功',$result);
  646. }
  647. /**
  648. * @Title("实名认证")
  649. * @Method("post")
  650. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  651. * @Header("api-token",type="string",require=1,default="",desc="token")
  652. * @Param("username",type="string",require=1,default="",desc="真实姓名")
  653. * @Param("id_card",type="string",require=1,default="",desc="身份证号")
  654. * @Param("CertifyId",type="string",require=1,default="",desc="CertifyId")
  655. */
  656. public function userCertification()
  657. {
  658. $user = $this->getUser();
  659. if ($user['is_auth']) $this->error('已实名认证');
  660. $data = $this->_vali([
  661. 'username.require'=>'真实姓名必须',
  662. 'id_card.require'=>'身份证号必须',
  663. 'is_auth.default'=>1,
  664. 'CertifyId.require'=>'CertifyId必须'
  665. ]);
  666. if (!isCreditNo($data['id_card'])) $this->error('身份证号格式错误');
  667. DataUser::mk()->where('id_card',$data['id_card'])->count() ? $this->error('身份证号已认证过') : '';
  668. $data['real_name']=$data['username'];
  669. unset($data['username']);
  670. // 核验
  671. $res = check($data['CertifyId']);
  672. if(!$res) $this->error('认证失败');
  673. $result = json_decode(json_encode($res),true)['body'];
  674. if($result['code'] != 200) $this->error($result['message']);
  675. unset($data['CertifyId']);
  676. if (DataUser::mk()->where(['id' => $this->uuid])->update($data) !== false) {
  677. $this->success('实名认证成功!');
  678. } else {
  679. $this->error('实名认证失败!');
  680. }
  681. }
  682. /**
  683. * @Title("钱包-我的余额")
  684. * @Method("post")
  685. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  686. * @Header("api-token",type="string",require=1,default="",desc="token")
  687. */
  688. public function moneylog(){
  689. $user = $this->getUser();
  690. $list = DataUserMoneyLog::Show($this->uuid)->paginate();
  691. $money = $user['money'];
  692. $bank_count = DataUserBankCard::Show($this->uuid)->count();
  693. $this->success('成功',compact('money','bank_count','list'));
  694. }
  695. /**
  696. * @Title("钱包-我的银行卡列表")
  697. * @Method("post")
  698. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  699. * @Header("api-token",type="string",require=1,default="",desc="token")
  700. */
  701. public function mybanklist(){
  702. $list = DataUserBankCard::Show($this->uuid)->select();
  703. $this->success('成功',$list);
  704. }
  705. /**
  706. * @Title("绑定银行卡")
  707. * @Method("post")
  708. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  709. * @Header("api-token",type="string",require=1,default="",desc="token")
  710. * @Param("name",type="string",require=1,default="",desc="姓名")
  711. * @Param("id_card",type="string",require=1,default="",desc="银行卡号")
  712. * @Param("id",type="string",require=0,default="",desc="修改,则必传之前提交的ID")
  713. */
  714. public function bind_bank(){
  715. $data = $this->_vali([
  716. 'uuid'=>$this->uuid,
  717. 'name.require'=>'姓名必须',
  718. 'id_card.require'=>'卡号必须',
  719. ]);
  720. !checkbank($data['id_card']) ? $this->error('卡号不正确') : '';
  721. $bank_name = bankInfo($data['id_card']);
  722. empty($bank_name) ? $this->error('卡号不正确或未录入') : '';
  723. $data['card_name'] = $bank_name;
  724. $id = input('id');
  725. DataUserBankCard::Show($this->uuid,$data['id_card'],$id)->count() ? $this->error('卡号已存在') : '';
  726. empty($id) ? : $data['update_at']=date('Y-m-d H:i:s');
  727. if (empty($id) ? DataUserBankCard::mk()->insert($data) : DataUserBankCard::mk()->where('id',$id)->update($data)){
  728. $this->success('提交成功');
  729. }
  730. $this->error('提交失败,请稍后重试');
  731. }
  732. /**
  733. * @Title("删除银行卡")
  734. * @Method("post")
  735. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  736. * @Header("api-token",type="string",require=1,default="",desc="token")
  737. * @Param("id",type="string",require=0,default="",desc="修改,则必传之前提交的ID")
  738. */
  739. public function delbank(){
  740. $data = $this->_vali([
  741. 'id.require'=>'id必须',
  742. ]);
  743. if (DataUserBankCard::mk()->where('id',$data['id'])->update(['is_del'=>0,'update_at'=>date('Y-m-d H:i:s')])){
  744. $this->success('删除成功');
  745. }
  746. $this->error('删除失败,请稍后重试');
  747. }
  748. /**
  749. * @Title("获取提现信息")
  750. * @Method("post")
  751. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  752. * @Header("api-token",type="string",require=1,default="",desc="token")
  753. *
  754. * @Returned("withdraw_min_price",desc="最低提现金额")
  755. * @Returned("withdraw_max_price",desc="最大提现金额")
  756. * @Returned("poundage_proportion",desc="手续费百分比")
  757. * @Returned("money",desc="用户可提现余额")
  758. */
  759. public function getwithinfo(){
  760. $user = $this->getUser();
  761. $info= [
  762. 'withdraw_min_price'=>sysconf('user.withdraw_min_price'),
  763. 'withdraw_max_price'=>sysconf('user.withdraw_max_price'),
  764. 'poundage_proportion'=>sysconf('user.poundage_proportion'),
  765. 'money'=>$user['money']
  766. ];
  767. $this->success('成功',$info);
  768. }
  769. /**
  770. * @Title("提现")
  771. * @Method("post")
  772. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  773. * @Header("api-token",type="string",require=1,default="",desc="token")
  774. * @Param("money",type="string",require=1,default="",desc="提现金额")
  775. * @Param("bind_id",type="string",require=0,default="",desc="绑定的银行卡记录ID")
  776. */
  777. public function withdraw(){
  778. $user=$this->getUser();
  779. $data = $this->_vali([
  780. 'money.require'=>'金额必须',
  781. 'bind_id.require'=>'绑定的记录ID必须',
  782. ]);
  783. $money = $data['money'];
  784. isAmount($money) ? : $this->error('金额错误');
  785. $user['money']<$money ? $this->error('余额不足') : '';
  786. $bank = DataUserBankCard::mk()->where('id',$data['bind_id'])->where('uuid',$this->uuid)->where('is_del',1)->findOrEmpty();
  787. if ($bank->isEmpty()) $this->error('绑定记录不存在');
  788. $withdraw_min_price = sysconf('user.withdraw_min_price'); //最小提现金额
  789. $withdraw_max_price = sysconf('user.withdraw_max_price'); //最大提现金额
  790. $poundage_proportion = sysconf('user.poundage_proportion'); //手续费百分比
  791. $money < $withdraw_min_price ? $this->error('最低提现'.$withdraw_min_price.'元') : '';
  792. $money > $withdraw_max_price ? $this->error('最大提现'.$withdraw_min_price.'元') : '';
  793. $error = 1;
  794. Db::startTrans();
  795. try {
  796. $proportion = sprintf("%.2f", $money*($poundage_proportion/100)); //四舍五入保留两位小数点
  797. $real_money = bcsub($money,$proportion,2);
  798. $inset = [
  799. 'uuid'=>$this->uuid,
  800. 'order_no'=>setorderno($this->uuid),
  801. 'bink_id'=>$data['bind_id'],
  802. 'card_name'=>$bank['card_name'],
  803. 'name'=>$bank['name'],
  804. 'bank_id_card'=>$bank['id_card'],
  805. 'price'=>$money,
  806. 'poundage_proportion'=>$poundage_proportion,
  807. 'proportion'=>$proportion,
  808. 'real_money'=>$real_money
  809. ];
  810. $id = DataUserWithdraw::mk()->insertGetId($inset);
  811. //余额提现
  812. $res = userMoneyChange($money,1,$this->uuid,'余额提现',0,$id);
  813. if (!$res){
  814. $error = 0;
  815. $errorinfo = '提现失败';
  816. Db::rollback();
  817. }
  818. Db::commit();
  819. } catch (\Exception $e) {
  820. // 回滚事务
  821. Db::rollback();
  822. $error = 0;
  823. $errorinfo = '未知错误';
  824. }
  825. if ($error){
  826. $this->success('提现成功,等待审核');
  827. }
  828. $this->error($errorinfo);
  829. }
  830. /**
  831. * @Title("意见反馈列表")
  832. * @Method("post")
  833. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  834. * @Header("api-token",type="string",require=1,default="",desc="token")
  835. * @Param("page&limit",type="string",require=0,default="",desc="分页")
  836. */
  837. public function feedbacklist(){
  838. $list = DataFeedback::Show($this->uuid)->with(['reply'])->paginate();
  839. $this->success('成功',$list);
  840. }
  841. /**
  842. * @Title("意见反馈提交")
  843. * @Method("post")
  844. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  845. * @Header("api-token",type="string",require=1,default="",desc="token")
  846. * @Param("content",type="string",require=1,default="",desc="反馈内容")
  847. * @Param("imgs",type="string",require=0,default="",desc="图片,以逗号隔开")
  848. * @Param("phone",type="string",require=0,default="",desc="手机号")
  849. * @Param("id",type="string",require=0,default="",desc="修改,则必传之前提交的ID,只有未回复的能修改")
  850. */
  851. public function subfeedback(){
  852. $data = $this->_vali([
  853. 'uuid'=>$this->uuid,
  854. 'content.require'=>'反馈内容必须',
  855. 'imgs.default'=>'',
  856. 'phone.default'=>''
  857. ]);
  858. empty($id) ? : $data['update_at']=date('Y-m-d H:i:s');
  859. if (empty($id) ? DataFeedback::mk()->insert($data) : DataFeedback::mk()->where('id',$id)->update($data)){
  860. $this->success('提交成功');
  861. }
  862. $this->error('提交失败,请稍后重试');
  863. }
  864. /**
  865. * @Title("意见反馈删除")
  866. * @Method("post")
  867. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  868. * @Header("api-token",type="string",require=1,default="",desc="token")
  869. * @Param("id",type="string",require=1,default="",desc="反馈ID")
  870. */
  871. public function delfeedback(){
  872. $data = $this->_vali([
  873. 'id.require'=>'ID必须',
  874. 'is_del.default'=>'0',
  875. ]);
  876. $id = $data['id'];
  877. unset($data['id']);
  878. DataFeedback::Show($this->uuid,$id)->count() ? '' : $this->error('信息不存在');
  879. if (DataFeedback::mk()->where('id',$id)->update($data)){
  880. $this->success('删除成功');
  881. }
  882. $this->error('删除失败,请稍后重试');
  883. }
  884. /**
  885. * @Title("我的收藏列表")
  886. * @Method("post")
  887. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  888. * @Header("api-token",type="string",require=1,default="",desc="token")
  889. * @Param("type",type="string",require=1,default="",desc="1:知识教学2:百知文库3:采购订单4应聘信息,5:船厂")
  890. * @Param("longitude",type="string",require=1,default="",desc="经度,船厂必须")
  891. * @Param("latitude",type="string",require=1,default="",desc="纬度,船厂必须")
  892. * @Returned("shipyard",desc="船厂对象")
  893. * @Returned("shipyard.distance",desc="船厂距离你的距离km")
  894. */
  895. public function mycollection(){
  896. $data = $this->_vali([
  897. 'type.require|in:1,2,3,4,5'=>'type有误'
  898. ]);
  899. switch ($data['type']){
  900. case 1:
  901. $list = DataCollectionLog::mk()
  902. ->hasWhere('knowledge',function (Query $query){
  903. $query->where('is_del',1);
  904. })
  905. ->where('data_collection_log.uuid',$this->uuid)
  906. ->where('cate',1)
  907. ->where('data_collection_log.type',1)
  908. ->with(['knowledge'=>function($query){
  909. $query->with(['user'=>function($query){
  910. $query->field('id,nickname,headimg,is_auth,is_vip');
  911. }]);
  912. }])
  913. ->order('id desc')
  914. ->paginate();
  915. break;
  916. case 2:
  917. $list = DataCollectionLog::mk()
  918. ->hasWhere('knowledge',function (Query $query){
  919. $query->where('is_del',1);
  920. })
  921. ->where('data_collection_log.uuid',$this->uuid)
  922. ->where('cate',2)
  923. ->where('data_collection_log.type',2)
  924. ->with(['knowledge'=>function($query){
  925. $query->with(['user'=>function($query){
  926. $query->field('id,nickname,headimg,is_auth,is_vip');
  927. }]);
  928. }])
  929. ->order('id desc')
  930. ->paginate();
  931. break;
  932. case 3:
  933. $list = ShopFavourite::mk()
  934. ->where('user_id',$this->uuid)
  935. ->order('id desc')
  936. ->paginate()
  937. ->toArray();
  938. foreach ($list['data'] as &$v){
  939. switch ($v['target_type']){
  940. case 'shop_purchase':
  941. $v['info'] = ShopPurchase::mk()
  942. ->where('id',$v['target_id'])
  943. ->with(['items','merchant'])
  944. ->findOrFail();
  945. break;
  946. case 'shop_production':
  947. $v['info'] = ShopProduction::mk()
  948. ->where('id',$v['target_id'])
  949. ->with(['items','merchant'])
  950. ->findOrFail();
  951. break;
  952. case 'shop_coordination':
  953. $v['info'] = ShopCoordination::mk()
  954. ->where('id',$v['target_id'])
  955. ->with(['items','merchant'])
  956. ->findOrFail();
  957. break;
  958. case 'shop_ocean':
  959. $v['info'] = ShopOcean::mk()
  960. ->where('id',$v['target_id'])
  961. ->with(['items','merchant'])
  962. ->findOrFail();
  963. break;
  964. }
  965. }
  966. break;
  967. case 4:
  968. $list = [];
  969. break;
  970. case 5:
  971. $data = $this->_vali([
  972. 'longitude.require'=>'经度必须',
  973. 'longitude.float'=>'经纬度必须是数字',
  974. 'latitude.require'=>'纬度必须',
  975. 'latitude.float'=>'经纬度必须是数字',
  976. ]);
  977. $list = DataCollectionLog::hasShipyard()
  978. ->where('uuid',$this->uuid)
  979. ->with(['shipyard'])
  980. ->paginate();
  981. foreach ($list as $item){
  982. $item['shipyard']->makeDistance($data['longitude'],$data['latitude']);
  983. }
  984. break;
  985. }
  986. $this->success('成功',$list);
  987. }
  988. /**
  989. * @Title("我的发布列表")
  990. * @Method("post")
  991. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  992. * @Header("api-token",type="string",require=1,default="",desc="token")
  993. * @Param("type",type="string",require=1,default="",desc="1:知识教学2:百知文库3:应聘信息")
  994. * @Returned("audit",desc="1:待审核2:审核成功3:审核失败")
  995. * @Returned("why",desc="审核失败原因")
  996. */
  997. public function myrelease(){
  998. $data = $this->_vali([
  999. 'type.require|in:1,2,3'=>'type有误'
  1000. ]);
  1001. switch ($data['type']){
  1002. case 1:
  1003. $list = DataTeachingKnowledge::mk()
  1004. ->where('uuid',$this->uuid)
  1005. ->where('is_del',1)
  1006. ->with(['user'=>function($query){
  1007. $query->field('id,headimg,nickname');
  1008. }])
  1009. ->order('id desc')
  1010. ->paginate();
  1011. break;
  1012. case 2:
  1013. $list = DataBestKnowledge::mk()
  1014. ->where('uuid',$this->uuid)
  1015. ->where('is_del',1)
  1016. ->with(['user'=>function($query){
  1017. $query->field('id,headimg,nickname');
  1018. },'classTo'])
  1019. ->paginate();
  1020. break;
  1021. case 3:
  1022. $list = DataUserApplyJobInfo::mk()
  1023. ->where('uuid',$this->uuid)
  1024. ->with(['workexperience','professionalskills','certificate'])
  1025. ->findOrEmpty();
  1026. if (!isset($list['id'])) $list = null;
  1027. break;
  1028. }
  1029. $this->success('成功',$list);
  1030. }
  1031. /**
  1032. * @Title("应聘信息隐藏,取消隐藏")
  1033. * @Method("post")
  1034. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1035. * @Header("api-token",type="string",require=1,default="",desc="token")
  1036. * @Param("hidden",type="string",require=1,default="",desc="0:隐藏 1:显示")
  1037. */
  1038. public function canhidden(){
  1039. $data = $this->_vali([
  1040. 'hidden.require|in:0,1'=>'字段有误',
  1041. 'update_at.default'=>date('Y-m-d H:i:s')
  1042. ]);
  1043. DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->findOrEmpty() ? : $this->error('未提交') ;
  1044. if (DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->update($data)){
  1045. $this->success('成功');
  1046. }
  1047. $this->error('失败');
  1048. }
  1049. /**
  1050. * @Title("我的需求")
  1051. * @Method("post")
  1052. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1053. * @Header("api-token",type="string",require=1,default="",desc="token")
  1054. * @Param("type",type="string",require=1,default="",desc="1:采购接单需求2:船机修理接单需求")
  1055. */
  1056. public function myneed(){
  1057. $data = $this->_vali([
  1058. 'type.require|in:1,2'=>'字段有误',
  1059. ]);
  1060. switch ($data['type']){
  1061. case 1:
  1062. $info = DataUserPurchaseAcceptance::mk()
  1063. ->where('uuid',$this->uuid)
  1064. ->findOrEmpty();
  1065. if (!isset($info['id'])) $info = null;
  1066. break;
  1067. case 2:
  1068. $info = DataUserAcceptance::mk()
  1069. ->where('uuid',$this->uuid)
  1070. ->findOrEmpty();
  1071. break;
  1072. }
  1073. $this->success('成功',$info);
  1074. }
  1075. /**
  1076. * @Title("发布、修改采购接单需求")
  1077. * @Method("post")
  1078. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1079. * @Header("api-token",type="string",require=1,default="",desc="token")
  1080. * @Param("description",type="string",require=1,default="",desc="需求说明")
  1081. * @Param("business_img",type="string",require=1,default="",desc="营业执照或身份证照")
  1082. * @Param("imgs",type="string",require=1,default="",desc="图片及资质证件图片,多个以英文逗号隔开")
  1083. * @Param("hidden",type="string",require=0,default="1",desc="是否隐藏1:不隐藏 2:隐藏")
  1084. * @Param("province",type="string",require=1,default="",desc="定位-省")
  1085. * @Param("city",type="string",require=1,default="",desc="定位-市")
  1086. * @Param("area",type="string",require=1,default="",desc="定位-区")
  1087. * @Param("id",type="string",require=0,default="",desc="修改时,传ID")
  1088. */
  1089. public function subpurchaseacceptance(){
  1090. $data = $this->_vali([
  1091. 'uuid.default'=>$this->uuid,
  1092. 'description.require'=>'需求说明必须',
  1093. 'business_img.require'=>'营业执照或身份证照必须',
  1094. 'imgs.require'=>'图片及资质证件图片必须',
  1095. 'province.require'=>'定位-省',
  1096. 'city.require'=>'定位-市',
  1097. 'area.require'=>'定位-区',
  1098. 'hidden.default'=>1
  1099. ]);
  1100. $id = input('id');
  1101. empty($id) ? $id = DataUserPurchaseAcceptance::mk()->where('uuid',$this->uuid)->value('id') : '' ;
  1102. empty($id) ? : $data['update_at']=date('Y-m-d H:i:s');
  1103. empty($id) ? : $data['create_at']=date('Y-m-d H:i:s');
  1104. !empty($id) ? (DataUserPurchaseAcceptance::mk()->where('uuid',$this->uuid)->where('id',$id)->value('status') == 2 ? $data['status'] = 0: '') : '';
  1105. if (empty($id) ? DataUserPurchaseAcceptance::mk()->insert($data) : DataUserPurchaseAcceptance::mk()->where('id',$id)->update($data)){
  1106. $this->success('提交成功');
  1107. }
  1108. $this->error('提交失败,请稍后重试');
  1109. }
  1110. /**
  1111. * @Title("维修订单")
  1112. * @Method("post")
  1113. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1114. * @Header("api-token",type="string",require=1,default="",desc="token")
  1115. * @Param("type",type="string",require=1,default="",desc="1:我是船老板2:我是维修工")
  1116. * @Param("status",type="string",require=1,default="",desc="1:未报价2:已报价3:已匹配")
  1117. */
  1118. public function repair(){
  1119. $data = $this->_vali([
  1120. 'type.require|in:1,2'=>'字段有误',
  1121. 'status.require|in:1,2,3'=>'字段有误',
  1122. ]);
  1123. switch ($data['type']){
  1124. case 1:
  1125. $list = DataUserRepair::mk()
  1126. ->where('uuid',$this->uuid)
  1127. ->where('status',$data['status'])
  1128. ->where('is_del',1)
  1129. ->paginate();
  1130. break;
  1131. case 2:
  1132. $status = $data['status'];
  1133. $list = DataUserRepairOffer::mk()
  1134. ->hasWhere('repair',function (Query $query){
  1135. $query->where('is_del',1);
  1136. })
  1137. ->with(['repair'=>function($query){
  1138. $query->withoutField('is_del,update_at');
  1139. }])
  1140. ->where('offer_id',$this->uuid)
  1141. ->where(function ($query) use ($status){
  1142. $repair_ids = DataUserRepairOffer::mk()
  1143. ->where('offer_id',$this->uuid)
  1144. ->where('price','>',0)
  1145. ->group('repair_id')
  1146. ->column('repair_id');
  1147. switch ($status){
  1148. case 1:
  1149. $query->whereNotIn('repair_id',$repair_ids)->where('is_deal',0)->where('status',2);
  1150. break;
  1151. case 2:
  1152. $query->whereIn('repair_id',$repair_ids)->where('is_deal',0)->where('status',2);
  1153. break;
  1154. case 3:
  1155. $query->where('is_deal',1)->where('status',3);
  1156. break;
  1157. }
  1158. })
  1159. ->field('data_user_repair_offer.id,repair_id,offer_id')
  1160. ->order('id desc')
  1161. ->group('repair_id')
  1162. ->paginate();
  1163. $list = $list->toArray();
  1164. foreach ($list['data'] as &$v){
  1165. $in = DataUserRepairOffer::mk()
  1166. ->where('repair_id',$v['repair_id'])
  1167. ->where('offer_id',$v['offer_id'])
  1168. ->order('id desc')
  1169. ->limit(1)
  1170. ->field('id,price')->find();
  1171. $v['price'] = $in->price;
  1172. }
  1173. break;
  1174. }
  1175. $this->success('成功',$list);
  1176. }
  1177. /**
  1178. * @Title("维修订单删除(只有维修订单未报价和已报价可以删除)")
  1179. * @Method("post")
  1180. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1181. * @Header("api-token",type="string",require=1,default="",desc="token")
  1182. * @Param("id",type="string",require=1,default="",desc="type为1时:维修单ID type为2时报价记录ID")
  1183. */
  1184. public function repairdel(){
  1185. $data = $this->_vali([
  1186. 'id.require'=>'id有误',
  1187. ]);
  1188. if (DataUserRepair::mk()->where('id',$data['id'])->where('uuid',$this->uuid)->update(['is_del'=>0])){
  1189. $this->success('成功');
  1190. }
  1191. $this->error('失败');
  1192. }
  1193. /**
  1194. * @Title("维修订单详情页")
  1195. * @Method("post")
  1196. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1197. * @Header("api-token",type="string",require=1,default="",desc="token")
  1198. * @Param("type",type="string",require=1,default="",desc="1:我是船老板2:我是维修工")
  1199. * @Param("id",type="string",require=1,default="",desc="type为1时:维修单ID type为2时报价记录ID")
  1200. */
  1201. public function repairdetail(){
  1202. $data = $this->_vali([
  1203. 'type.require|in:1,2'=>'字段有误',
  1204. 'id.require'=>'id有误',
  1205. ]);
  1206. //$this->uuid = 69;
  1207. switch ($data['type']){
  1208. case 1:
  1209. $info = DataUserRepair::mk()
  1210. ->where('uuid',$this->uuid)
  1211. ->where('is_del',1)
  1212. ->where('id',$data['id'])
  1213. ->with(['user'=>function($query){
  1214. $query->field('id,nickname,headimg,phone');
  1215. },'offer'=>function($query){
  1216. $query->field('id,repair_id,offer_id,price,imgs')->group('offer_id')
  1217. ->with(['user'=>function($query){
  1218. $query->field('id,nickname,headimg,phone');
  1219. }]);
  1220. },'success'=>function($query){
  1221. $query->field('id,nickname,headimg,phone');
  1222. }])
  1223. ->find()->toArray();
  1224. foreach ($info['offer'] as &$v){
  1225. $in = DataUserRepairOffer::mk()
  1226. ->where('repair_id',$data['id'])
  1227. ->where('offer_id',$v['offer_id'])
  1228. ->order('id desc')
  1229. ->limit(1)
  1230. ->field('id,price')->find();
  1231. $v['id'] = $in->id;
  1232. $v['price'] = $in->price;
  1233. }
  1234. break;
  1235. case 2:
  1236. $info = DataUserRepairOffer::mk()
  1237. ->where('id',$data['id'])
  1238. ->with(['user'=>function($query){
  1239. $query->field('id,nickname,headimg,phone');
  1240. },'repair'=>function($query){
  1241. $query->with(['user'=>function($query){
  1242. $query->field('id,nickname,headimg,phone');
  1243. }]);
  1244. }])
  1245. ->find()->toArray();
  1246. $in = DataUserRepairOffer::mk()
  1247. ->where('repair_id',$info['repair_id'])
  1248. ->where('offer_id',$info['offer_id'])
  1249. ->order('id desc')
  1250. ->limit(1)
  1251. ->field('id,price')->find();
  1252. $info['price'] = $in['price'];
  1253. break;
  1254. }
  1255. $this->success('成功',$info);
  1256. }
  1257. /**
  1258. * @Title("维修订单确认匹配")
  1259. * @Method("post")
  1260. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1261. * @Header("api-token",type="string",require=1,default="",desc="token")
  1262. * @Param("id",type="string",require=1,default="",desc="维修单ID")
  1263. * @Param("offer_id",type="string",require=1,default="",desc="匹配的记录ID")
  1264. */
  1265. public function repairoffer(){
  1266. $data = $this->_vali([
  1267. 'id.require'=>'id有误',
  1268. 'offer_id.require'=>'offer_id有误',
  1269. ]);
  1270. DataUserRepair::mk()->where('id',$data['id'])->value('status') == 3 ? $this->error('订单已经匹配成功') : '';
  1271. $offer = DataUserRepairOffer::mk()->where('id',$data['offer_id'])->find();
  1272. 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')])
  1273. &&
  1274. DataUserRepairOffer::mk()->where('id',$data['offer_id'])->update(['is_deal'=>1,'deal_at'=>date('Y-m-d H:i:s')])){
  1275. $url = setword(1,$data['id']);
  1276. DataUserRepair::mk()->where('id',$data['id'])->update(['down_word'=>$url]);
  1277. $this->success('成功');
  1278. }
  1279. $this->error('失败');
  1280. }
  1281. /**
  1282. * @Title("维修订单详情页用户报价列表点击查看详情")
  1283. * @Method("post")
  1284. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1285. * @Header("api-token",type="string",require=1,default="",desc="token")
  1286. * @Param("id",type="string",require=1,default="",desc="维修单ID")
  1287. * @Param("offer_id",type="string",require=1,default="",desc="匹配的offer_id")
  1288. */
  1289. public function userofferinfo(){
  1290. $data = $this->_vali([
  1291. 'id.require'=>'id有误',
  1292. 'offer_id.require'=>'offer_id有误',
  1293. ]);
  1294. // $this->uuid = 69;
  1295. $offer_id = $data['offer_id'];
  1296. $list = DataUserRepairOffer::mk()
  1297. ->where('repair_id',$data['id'])
  1298. ->where(function ($query) use ($offer_id){
  1299. $query->where('offer_id',$offer_id);
  1300. })
  1301. ->field('id,price')
  1302. ->select();
  1303. $imgs = array_filter(explode(',',DataUserRepairOffer::mk()->where('repair_id',$data['id'])
  1304. ->where('offer_id',$offer_id)
  1305. ->order('id desc')
  1306. ->limit(1)
  1307. ->value('imgs')));
  1308. $messagelist = DataUserLeaveMessage::mk()
  1309. ->where('type',1)
  1310. ->whereRaw("(uuid=$this->uuid and uuid2=$offer_id) or (uuid2=$this->uuid and uuid=$offer_id)")
  1311. ->where('link_id',$data['id'])
  1312. ->with(['user'=>function($query){
  1313. $query->field('id,nickname,headimg');
  1314. }])
  1315. ->field('id,uuid,uuid2,content,create_at')
  1316. ->select();
  1317. $this->success('成功',compact('list','imgs','messagelist'));
  1318. }
  1319. /**
  1320. * @Title("维修订单留言")
  1321. * @Method("post")
  1322. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1323. * @Header("api-token",type="string",require=1,default="",desc="token")
  1324. * @Param("id",type="string",require=1,default="",desc="维修单ID")
  1325. * @Param("offer_id",type="string",require=1,default="",desc="匹配的记录ID")
  1326. * @Param("content",type="string",require=1,default="",desc="内容")
  1327. */
  1328. public function subleavemessage(){
  1329. $data = $this->_vali([
  1330. 'id.require'=>'id有误',
  1331. 'offer_id.require'=>'offer_id有误',
  1332. 'content.require'=>'内容必须',
  1333. ]);
  1334. $offer = DataUserRepairOffer::mk()->where('id',$data['offer_id'])->findOrEmpty();
  1335. $array = [
  1336. 'uuid'=>$this->uuid,
  1337. 'uuid2'=>$offer->offer_id,
  1338. 'content'=>$data['content'],
  1339. 'type'=>1,
  1340. 'link_id'=>$data['id'],
  1341. ];
  1342. if (DataUserLeaveMessage::mk()->insert($array)){
  1343. $this->success('成功');
  1344. }
  1345. $this->error('失败');
  1346. }
  1347. /**
  1348. * @Title("维修订单维修工回复留言")
  1349. * @Method("post")
  1350. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1351. * @Header("api-token",type="string",require=1,default="",desc="token")
  1352. * @Param("id",type="string",require=1,default="",desc="维修单ID")
  1353. * @Param("content",type="string",require=1,default="",desc="内容")
  1354. */
  1355. public function subofferleavemessage(){
  1356. $data = $this->_vali([
  1357. 'id.require'=>'id有误',
  1358. 'content.require'=>'内容必须',
  1359. ]);
  1360. $repair = DataUserRepair::mk()->where('id',$data['id'])->findOrEmpty();
  1361. $array = [
  1362. 'uuid'=>$this->uuid,
  1363. 'uuid2'=>$repair->uuid,
  1364. 'content'=>$data['content'],
  1365. 'type'=>1,
  1366. 'link_id'=>$data['id'],
  1367. ];
  1368. if (DataUserLeaveMessage::mk()->insert($array)){
  1369. $this->success('成功');
  1370. }
  1371. $this->error('失败');
  1372. }
  1373. /**
  1374. * @Title("维修订单维修工查看留言列表")
  1375. * @Method("post")
  1376. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1377. * @Header("api-token",type="string",require=1,default="",desc="token")
  1378. * @Param("id",type="string",require=1,default="",desc="维修单ID")
  1379. */
  1380. public function suboffermessagelist(){
  1381. $data = $this->_vali([
  1382. 'id.require'=>'id有误',
  1383. ]);
  1384. // $this->uuid = 54;
  1385. $uid = DataUserRepair::mk()->where('id',$data['id'])->value('uuid');
  1386. if (!$uid) $this->error('订单未找到');
  1387. $messagelist = DataUserLeaveMessage::mk()
  1388. ->where('type',1)
  1389. ->where('link_id',$data['id'])
  1390. ->whereRaw("(uuid=$this->uuid and uuid2=$uid) or uuid2=$this->uuid and uuid=$uid")
  1391. // ->whereRaw("uuid=$this->uuid or uuid2=$this->uuid")
  1392. ->with(['user'=>function($query){
  1393. $query->field('id,nickname,headimg');
  1394. }])
  1395. ->field('id,uuid,uuid2,content,create_at')
  1396. ->select();
  1397. $this->success('成功',$messagelist);
  1398. }
  1399. /**
  1400. * @Title("消息未读数量")
  1401. * @Method("post")
  1402. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1403. * @Header("api-token",type="string",require=1,default="",desc="token")
  1404. * @Returned("message_count",desc="后台消息未读数量")
  1405. * @Returned("notice_count",desc="系统通知未读数量")
  1406. */
  1407. public function messagenoread(){
  1408. $message = BaseUserMessage::mk()->where('type','message')->where('status',1)
  1409. ->where('deleted',0)->column('id');
  1410. $notice = BaseUserMessage::mk()->where('type','notice')->where('status',1)
  1411. ->where('deleted',0)->column('id');
  1412. $message_read_count = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->whereIn('message_id',$message)->count();
  1413. $notice_read_count = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->whereIn('message_id',$notice)->count();
  1414. $array = [
  1415. 'message_count'=>count($message)-$message_read_count,
  1416. 'notice_count'=>count($notice)-$notice_read_count
  1417. ];
  1418. $this->success('成功',$array);
  1419. }
  1420. /**
  1421. * @Title("消息")
  1422. * @Method("post")
  1423. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1424. * @Header("api-token",type="string",require=1,default="",desc="token")
  1425. * @Param("type",type="string",require=1,default="",desc="message:后台消息 notice:系统通知")
  1426. * @Returned("is_read",desc="1:已读 0:未读")
  1427. */
  1428. public function messagelist(){
  1429. $data = $this->_vali([
  1430. 'type.require'=>'type有误',
  1431. ]);
  1432. $type = $data['type'];
  1433. $messagelist = BaseUserMessage::mk()
  1434. ->where('type',$data['type'])
  1435. ->when($type,function ($query) use ($type){
  1436. if ($type=='notice'){
  1437. $query->where('uuid',$this->uuid);
  1438. }
  1439. })
  1440. ->where('status',1)
  1441. ->where('deleted',0)
  1442. ->withoutField('deleted,sort,num_read,status')
  1443. ->order('id desc')
  1444. ->paginate()->toArray();
  1445. foreach ($messagelist['data'] as &$v){
  1446. $v['is_read'] = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->where('message_id',$v['id'])->count() ? 1 : 0;
  1447. }
  1448. $this->success('成功',$messagelist);
  1449. }
  1450. /**
  1451. * @Title("点击消息")
  1452. * @Method("post")
  1453. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1454. * @Header("api-token",type="string",require=1,default="",desc="token")
  1455. * @Param("id",type="string",require=1,default="",desc="消息ID")
  1456. */
  1457. public function readmessage(){
  1458. $data = $this->_vali([
  1459. 'id.require'=>'id有误',
  1460. ]);
  1461. $info = BaseUserMessage::mk()->where('id',$data['id'])->findOrEmpty();
  1462. BaseUserMessageRead::mk()->where('uuid',$this->uuid)->where('message_id',$data['id'])->count() ? :
  1463. BaseUserMessageRead::mk()->insert(['message_id'=>$data['id'],'uuid'=>$this->uuid]);
  1464. $this->success('成功',$info);
  1465. }
  1466. /**
  1467. * @Title("获取安卓版本")
  1468. * @Method("post")
  1469. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1470. * @Header("api-token",type="string",require=1,default="",desc="token")
  1471. *
  1472. * @Returned("version",desc="当前版本")
  1473. * @Returned("name",desc="版本名")
  1474. * @Returned("title",desc="更新标题")
  1475. * @Returned("isCompel",desc="1:强制更新 0:不强制更新")
  1476. * @Returned("content",desc="更新内容")
  1477. * @Returned("download_url",desc="下载地址")'
  1478. *
  1479. * @Returned("version2",desc="商家端当前版本")
  1480. * @Returned("name2",desc="商家端版本名")
  1481. * @Returned("title2",desc="商家端更新标题")
  1482. * @Returned("isCompel2",desc="商家端1:强制更新 0:不强制更新")
  1483. * @Returned("content2",desc="商家端更新内容")
  1484. * @Returned("download_url2",desc="商家端下载地址")
  1485. */
  1486. public function getandroidversion(){
  1487. $info= [
  1488. 'version'=>(int)sysconf('android.version'),
  1489. 'name'=>sysconf('android.name'),
  1490. 'title'=>sysconf('android.title'),
  1491. 'isCompel'=>(int)sysconf('android.isCompel'),
  1492. 'content'=>sysconf('android.content'),
  1493. 'download_url'=>sysconf('android.download_url'),
  1494. 'version2'=>(int)sysconf('android.version2'),
  1495. 'name2'=>sysconf('android.name2'),
  1496. 'title2'=>sysconf('android.title2'),
  1497. 'isCompel2'=>(int)sysconf('android.isCompel2'),
  1498. 'content2'=>sysconf('android.content2'),
  1499. 'download_url2'=>sysconf('android.download_url2'),
  1500. ];
  1501. $this->success('成功',$info);
  1502. }
  1503. /**
  1504. * @Title("获取ios版本")
  1505. * @Method("post")
  1506. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1507. * @Header("api-token",type="string",require=1,default="",desc="token")
  1508. *
  1509. * @Returned("version",desc="当前版本")
  1510. * @Returned("name",desc="版本名")
  1511. * @Returned("title",desc="更新标题")
  1512. * @Returned("isCompel",desc="1:强制更新 0:不强制更新")
  1513. * @Returned("content",desc="更新内容")
  1514. */
  1515. public function getiosversion(){
  1516. $info= [
  1517. 'version'=>(int)sysconf('ios.version'),
  1518. 'name'=>sysconf('ios.name'),
  1519. 'title'=>sysconf('ios.title'),
  1520. 'isCompel'=>(int)sysconf('ios.isCompel'),
  1521. 'content'=>sysconf('ios.content'),
  1522. // 'download_url'=>sysconf('android.download_url'),
  1523. ];
  1524. $this->success('成功',$info);
  1525. }
  1526. /**
  1527. * @Title("获取商家入驻规则、船厂入驻规则")
  1528. * @Method("post")
  1529. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1530. * @Header("api-token",type="string",require=1,default="",desc="token")
  1531. *
  1532. * @Returned("business_join_rule",desc="商家入驻规则")
  1533. * @Returned("shipyard_join_rule",desc="船厂入驻规则")
  1534. */
  1535. public function getrule(){
  1536. $info= [
  1537. 'business_join_rule'=>htmlspecialchars_decode(sysconf('business.business_join_rule')),
  1538. 'shipyard_join_rule'=>htmlspecialchars_decode(sysconf('shipyard.shipyard_join_rule')),
  1539. ];
  1540. $this->success('成功',$info);
  1541. }
  1542. /**
  1543. * @Title("账号注销")
  1544. * @Method("post")
  1545. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1546. * @Header("api-token",type="string",require=1,default="",desc="token")
  1547. *
  1548. */
  1549. public function cancellation(){
  1550. if (DataUser::mk()->where('id',$this->uuid)->update(['status'=>0])){
  1551. $this->success('注销成功');
  1552. }
  1553. $this->error('注销失败');
  1554. }
  1555. public function ccc(){
  1556. // $list = DataUserRepair::mk()->where('status',3)->select();
  1557. // foreach ($list as &$v){
  1558. // $url = setword(1,$v['id']);
  1559. // DataUserRepair::mk()->where('id',$v['id'])->update(['down_word'=>$url]);
  1560. // }
  1561. // die();
  1562. echo setword(4,5);
  1563. die;
  1564. // $dir = dirname(realpath(dirname($_SERVER['SCRIPT_FILENAME']))) . '/public/';
  1565. // $templateProcessor = new TemplateProcessor($dir.'/wxdd.docx');
  1566. // $templateProcessor->setValue('order_no','1234');
  1567. // $templateProcessor->setValue('date','2023-02-20 15:05:50');
  1568. // $templateProcessor->setValue('fbz','张三');
  1569. // $templateProcessor->setValue('jdf','李四');
  1570. // $templateProcessor->setValue('fbzphone','15800000000');
  1571. // $templateProcessor->setValue('jdfphone','15800000001');
  1572. // $templateProcessor->setValue('address','藕粉色大后方胡搜凤凰山佛山房');
  1573. // $templateProcessor->setValue('time','2023-02-20 15:10:00');
  1574. // $templateProcessor->setValue('desc','维修单维修单');
  1575. // $templateProcessor->setValue('price','100');
  1576. // $templateProcessor->saveAs($dir."b.docx");
  1577. $dir = dirname(realpath(dirname($_SERVER['SCRIPT_FILENAME']))) . '/public/';
  1578. $templateProcessor = new TemplateProcessor($dir.'/cgdd.docx');
  1579. $templateProcessor->setValue('order_no','2312312313');
  1580. $templateProcessor->cloneRow('id',3);
  1581. $templateProcessor->setValue('id#1', '1');
  1582. $templateProcessor->setValue('bh#1', '1');
  1583. $templateProcessor->setValue('name#1', '名称');
  1584. $templateProcessor->setValue('gg#1', '规格');
  1585. $templateProcessor->setValue('num#1', '10');
  1586. $templateProcessor->setValue('price#1', '10');
  1587. $templateProcessor->setValue('allprice#1', '20');
  1588. $templateProcessor->setValue('id#2', '1');
  1589. $templateProcessor->setValue('bh#2', '1');
  1590. $templateProcessor->setValue('name#2', '名称');
  1591. $templateProcessor->setValue('gg#2', '规格');
  1592. $templateProcessor->setValue('num#2', '10');
  1593. $templateProcessor->setValue('price#2', '10');
  1594. $templateProcessor->setValue('allprice#2', '20');
  1595. $templateProcessor->setValue('id#3', '1');
  1596. $templateProcessor->setValue('bh#3', '1');
  1597. $templateProcessor->setValue('name#3', '名称');
  1598. $templateProcessor->setValue('gg#3', '规格');
  1599. $templateProcessor->setValue('num#3', '10');
  1600. $templateProcessor->setValue('price#3', '10');
  1601. $templateProcessor->setValue('allprice#3', '20');
  1602. $templateProcessor->saveAs($dir."c.docx");
  1603. }
  1604. }