Center.php 79 KB

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