Center.php 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  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. $this->success('成功');
  1276. }
  1277. $this->error('失败');
  1278. }
  1279. /**
  1280. * @Title("维修订单详情页用户报价列表点击查看详情")
  1281. * @Method("post")
  1282. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1283. * @Header("api-token",type="string",require=1,default="",desc="token")
  1284. * @Param("id",type="string",require=1,default="",desc="维修单ID")
  1285. * @Param("offer_id",type="string",require=1,default="",desc="匹配的offer_id")
  1286. */
  1287. public function userofferinfo(){
  1288. $data = $this->_vali([
  1289. 'id.require'=>'id有误',
  1290. 'offer_id.require'=>'offer_id有误',
  1291. ]);
  1292. // $this->uuid = 69;
  1293. $offer_id = $data['offer_id'];
  1294. $list = DataUserRepairOffer::mk()
  1295. ->where('repair_id',$data['id'])
  1296. ->where(function ($query) use ($offer_id){
  1297. $query->where('offer_id',$offer_id);
  1298. })
  1299. ->field('id,price')
  1300. ->select();
  1301. $imgs = array_filter(explode(',',DataUserRepairOffer::mk()->where('repair_id',$data['id'])
  1302. ->where('offer_id',$offer_id)
  1303. ->order('id desc')
  1304. ->limit(1)
  1305. ->value('imgs')));
  1306. $messagelist = DataUserLeaveMessage::mk()
  1307. ->where('type',1)
  1308. ->whereRaw("(uuid=$this->uuid and uuid2=$offer_id) or (uuid2=$this->uuid and uuid=$offer_id)")
  1309. ->where('link_id',$data['id'])
  1310. ->with(['user'=>function($query){
  1311. $query->field('id,nickname,headimg');
  1312. }])
  1313. ->field('id,uuid,uuid2,content,create_at')
  1314. ->select();
  1315. $this->success('成功',compact('list','imgs','messagelist'));
  1316. }
  1317. /**
  1318. * @Title("维修订单留言")
  1319. * @Method("post")
  1320. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1321. * @Header("api-token",type="string",require=1,default="",desc="token")
  1322. * @Param("id",type="string",require=1,default="",desc="维修单ID")
  1323. * @Param("offer_id",type="string",require=1,default="",desc="匹配的记录ID")
  1324. * @Param("content",type="string",require=1,default="",desc="内容")
  1325. */
  1326. public function subleavemessage(){
  1327. $data = $this->_vali([
  1328. 'id.require'=>'id有误',
  1329. 'offer_id.require'=>'offer_id有误',
  1330. 'content.require'=>'内容必须',
  1331. ]);
  1332. $offer = DataUserRepairOffer::mk()->where('id',$data['offer_id'])->findOrEmpty();
  1333. $array = [
  1334. 'uuid'=>$this->uuid,
  1335. 'uuid2'=>$offer->offer_id,
  1336. 'content'=>$data['content'],
  1337. 'type'=>1,
  1338. 'link_id'=>$data['id'],
  1339. ];
  1340. if (DataUserLeaveMessage::mk()->insert($array)){
  1341. $this->success('成功');
  1342. }
  1343. $this->error('失败');
  1344. }
  1345. /**
  1346. * @Title("维修订单维修工回复留言")
  1347. * @Method("post")
  1348. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1349. * @Header("api-token",type="string",require=1,default="",desc="token")
  1350. * @Param("id",type="string",require=1,default="",desc="维修单ID")
  1351. * @Param("content",type="string",require=1,default="",desc="内容")
  1352. */
  1353. public function subofferleavemessage(){
  1354. $data = $this->_vali([
  1355. 'id.require'=>'id有误',
  1356. 'content.require'=>'内容必须',
  1357. ]);
  1358. $repair = DataUserRepair::mk()->where('id',$data['id'])->findOrEmpty();
  1359. $array = [
  1360. 'uuid'=>$this->uuid,
  1361. 'uuid2'=>$repair->uuid,
  1362. 'content'=>$data['content'],
  1363. 'type'=>1,
  1364. 'link_id'=>$data['id'],
  1365. ];
  1366. if (DataUserLeaveMessage::mk()->insert($array)){
  1367. $this->success('成功');
  1368. }
  1369. $this->error('失败');
  1370. }
  1371. /**
  1372. * @Title("维修订单维修工查看留言列表")
  1373. * @Method("post")
  1374. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1375. * @Header("api-token",type="string",require=1,default="",desc="token")
  1376. * @Param("id",type="string",require=1,default="",desc="维修单ID")
  1377. */
  1378. public function suboffermessagelist(){
  1379. $data = $this->_vali([
  1380. 'id.require'=>'id有误',
  1381. ]);
  1382. // $this->uuid = 54;
  1383. $uid = DataUserRepair::mk()->where('id',$data['id'])->value('uuid');
  1384. if (!$uid) $this->error('订单未找到');
  1385. $messagelist = DataUserLeaveMessage::mk()
  1386. ->where('type',1)
  1387. ->where('link_id',$data['id'])
  1388. ->whereRaw("(uuid=$this->uuid and uuid2=$uid) or uuid2=$this->uuid and uuid=$uid")
  1389. // ->whereRaw("uuid=$this->uuid or uuid2=$this->uuid")
  1390. ->with(['user'=>function($query){
  1391. $query->field('id,nickname,headimg');
  1392. }])
  1393. ->field('id,uuid,uuid2,content,create_at')
  1394. ->select();
  1395. $this->success('成功',$messagelist);
  1396. }
  1397. /**
  1398. * @Title("消息未读数量")
  1399. * @Method("post")
  1400. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1401. * @Header("api-token",type="string",require=1,default="",desc="token")
  1402. * @Returned("message_count",desc="后台消息未读数量")
  1403. * @Returned("notice_count",desc="系统通知未读数量")
  1404. */
  1405. public function messagenoread(){
  1406. $message = BaseUserMessage::mk()->where('type','message')->where('status',1)
  1407. ->where('deleted',0)->column('id');
  1408. $notice = BaseUserMessage::mk()->where('type','notice')->where('status',1)
  1409. ->where('deleted',0)->column('id');
  1410. $message_read_count = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->whereIn('message_id',$message)->count();
  1411. $notice_read_count = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->whereIn('message_id',$notice)->count();
  1412. $array = [
  1413. 'message_count'=>count($message)-$message_read_count,
  1414. 'notice_count'=>count($notice)-$notice_read_count
  1415. ];
  1416. $this->success('成功',$array);
  1417. }
  1418. /**
  1419. * @Title("消息")
  1420. * @Method("post")
  1421. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1422. * @Header("api-token",type="string",require=1,default="",desc="token")
  1423. * @Param("type",type="string",require=1,default="",desc="message:后台消息 notice:系统通知")
  1424. * @Returned("is_read",desc="1:已读 0:未读")
  1425. */
  1426. public function messagelist(){
  1427. $data = $this->_vali([
  1428. 'type.require'=>'type有误',
  1429. ]);
  1430. $type = $data['type'];
  1431. $messagelist = BaseUserMessage::mk()
  1432. ->where('type',$data['type'])
  1433. ->when($type,function ($query) use ($type){
  1434. if ($type=='notice'){
  1435. $query->where('uuid',$this->uuid);
  1436. }
  1437. })
  1438. ->where('status',1)
  1439. ->where('deleted',0)
  1440. ->withoutField('deleted,sort,num_read,status')
  1441. ->order('id desc')
  1442. ->paginate()->toArray();
  1443. foreach ($messagelist['data'] as &$v){
  1444. $v['is_read'] = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->where('message_id',$v['id'])->count() ? 1 : 0;
  1445. }
  1446. $this->success('成功',$messagelist);
  1447. }
  1448. /**
  1449. * @Title("点击消息")
  1450. * @Method("post")
  1451. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1452. * @Header("api-token",type="string",require=1,default="",desc="token")
  1453. * @Param("id",type="string",require=1,default="",desc="消息ID")
  1454. */
  1455. public function readmessage(){
  1456. $data = $this->_vali([
  1457. 'id.require'=>'id有误',
  1458. ]);
  1459. $info = BaseUserMessage::mk()->where('id',$data['id'])->findOrEmpty();
  1460. BaseUserMessageRead::mk()->where('uuid',$this->uuid)->where('message_id',$data['id'])->count() ? :
  1461. BaseUserMessageRead::mk()->insert(['message_id'=>$data['id'],'uuid'=>$this->uuid]);
  1462. $this->success('成功',$info);
  1463. }
  1464. /**
  1465. * @Title("获取安卓版本")
  1466. * @Method("post")
  1467. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1468. * @Header("api-token",type="string",require=1,default="",desc="token")
  1469. *
  1470. * @Returned("version",desc="当前版本")
  1471. * @Returned("name",desc="版本名")
  1472. * @Returned("title",desc="更新标题")
  1473. * @Returned("isCompel",desc="1:强制更新 0:不强制更新")
  1474. * @Returned("content",desc="更新内容")
  1475. * @Returned("download_url",desc="下载地址")'
  1476. *
  1477. * @Returned("version2",desc="商家端当前版本")
  1478. * @Returned("name2",desc="商家端版本名")
  1479. * @Returned("title2",desc="商家端更新标题")
  1480. * @Returned("isCompel2",desc="商家端1:强制更新 0:不强制更新")
  1481. * @Returned("content2",desc="商家端更新内容")
  1482. * @Returned("download_url2",desc="商家端下载地址")
  1483. */
  1484. public function getandroidversion(){
  1485. $info= [
  1486. 'version'=>(int)sysconf('android.version'),
  1487. 'name'=>sysconf('android.name'),
  1488. 'title'=>sysconf('android.title'),
  1489. 'isCompel'=>(int)sysconf('android.isCompel'),
  1490. 'content'=>sysconf('android.content'),
  1491. 'download_url'=>sysconf('android.download_url'),
  1492. 'version2'=>(int)sysconf('android.version2'),
  1493. 'name2'=>sysconf('android.name2'),
  1494. 'title2'=>sysconf('android.title2'),
  1495. 'isCompel2'=>(int)sysconf('android.isCompel2'),
  1496. 'content2'=>sysconf('android.content2'),
  1497. 'download_url2'=>sysconf('android.download_url2'),
  1498. ];
  1499. $this->success('成功',$info);
  1500. }
  1501. /**
  1502. * @Title("获取ios版本")
  1503. * @Method("post")
  1504. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1505. * @Header("api-token",type="string",require=1,default="",desc="token")
  1506. *
  1507. * @Returned("version",desc="当前版本")
  1508. * @Returned("name",desc="版本名")
  1509. * @Returned("title",desc="更新标题")
  1510. * @Returned("isCompel",desc="1:强制更新 0:不强制更新")
  1511. * @Returned("content",desc="更新内容")
  1512. */
  1513. public function getiosversion(){
  1514. $info= [
  1515. 'version'=>(int)sysconf('ios.version'),
  1516. 'name'=>sysconf('ios.name'),
  1517. 'title'=>sysconf('ios.title'),
  1518. 'isCompel'=>(int)sysconf('ios.isCompel'),
  1519. 'content'=>sysconf('ios.content'),
  1520. // 'download_url'=>sysconf('android.download_url'),
  1521. ];
  1522. $this->success('成功',$info);
  1523. }
  1524. /**
  1525. * @Title("获取商家入驻规则、船厂入驻规则")
  1526. * @Method("post")
  1527. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1528. * @Header("api-token",type="string",require=1,default="",desc="token")
  1529. *
  1530. * @Returned("business_join_rule",desc="商家入驻规则")
  1531. * @Returned("shipyard_join_rule",desc="船厂入驻规则")
  1532. */
  1533. public function getrule(){
  1534. $info= [
  1535. 'business_join_rule'=>htmlspecialchars_decode(sysconf('business.business_join_rule')),
  1536. 'shipyard_join_rule'=>htmlspecialchars_decode(sysconf('shipyard.shipyard_join_rule')),
  1537. ];
  1538. $this->success('成功',$info);
  1539. }
  1540. /**
  1541. * @Title("账号注销")
  1542. * @Method("post")
  1543. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  1544. * @Header("api-token",type="string",require=1,default="",desc="token")
  1545. *
  1546. */
  1547. public function cancellation(){
  1548. if (DataUser::mk()->where('id',$this->uuid)->update(['status'=>0])){
  1549. $this->success('注销成功');
  1550. }
  1551. $this->error('注销失败');
  1552. }
  1553. public function ccc(){
  1554. // $dir = dirname(realpath(dirname($_SERVER['SCRIPT_FILENAME']))) . '/public/';
  1555. // $templateProcessor = new TemplateProcessor($dir.'/wxdd.docx');
  1556. // $templateProcessor->setValue('order_no','1234');
  1557. // $templateProcessor->setValue('date','2023-02-20 15:05:50');
  1558. // $templateProcessor->setValue('fbz','张三');
  1559. // $templateProcessor->setValue('jdf','李四');
  1560. // $templateProcessor->setValue('fbzphone','15800000000');
  1561. // $templateProcessor->setValue('jdfphone','15800000001');
  1562. // $templateProcessor->setValue('address','藕粉色大后方胡搜凤凰山佛山房');
  1563. // $templateProcessor->setValue('time','2023-02-20 15:10:00');
  1564. // $templateProcessor->setValue('desc','维修单维修单');
  1565. // $templateProcessor->setValue('price','100');
  1566. // $templateProcessor->saveAs($dir."b.docx");
  1567. $dir = dirname(realpath(dirname($_SERVER['SCRIPT_FILENAME']))) . '/public/';
  1568. $templateProcessor = new TemplateProcessor($dir.'/cgdd.docx');
  1569. $templateProcessor->setValue('order_no','1234');
  1570. $templateProcessor->setValue('date','2023-02-20 15:05:50');
  1571. $templateProcessor->setValue('fbz','张三');
  1572. $templateProcessor->setValue('jdf','李四');
  1573. $templateProcessor->setValue('fbzphone','15800000000');
  1574. $templateProcessor->setValue('jdfphone','15800000001');
  1575. $templateProcessor->setValue('address','藕粉色大后方胡搜凤凰山佛山房');
  1576. $templateProcessor->setValue('time','2023-02-20 15:10:00');
  1577. $templateProcessor->setValue('desc','维修单维修单');
  1578. $templateProcessor->setValue('price','100');
  1579. $templateProcessor->saveAs($dir."b.docx");
  1580. }
  1581. }