Supplier.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\PlatformLike;
  4. use app\common\model\PressComment;
  5. use app\common\model\SupplierCate;
  6. use app\common\model\UserCollect;
  7. use app\common\model\UserSearch;
  8. use app\common\model\SupplierGoods;
  9. use app\common\model\UserTrack;
  10. use library\tools\Data;
  11. use think\Db;
  12. /**
  13. * @title 供应商
  14. * @controller Supplier
  15. * @group base
  16. */
  17. class Supplier extends Base
  18. {
  19. // 需要登录的
  20. protected $need_login = ['','',''];
  21. public function initialize()
  22. {
  23. parent::initialize();
  24. parent::setUid();
  25. }
  26. /**
  27. * @title 供应商接口说明
  28. * @desc 供应商接口说明
  29. * @author qc
  30. * @url /api/Supplier/classIntro
  31. * @method GET
  32. * @return name:1 type:string default:-- desc:--
  33. */
  34. public function classIntro(){}
  35. /**
  36. * @title 获取供应商分类
  37. * @desc 两级分类
  38. * @author qc
  39. * @url /api/Supplier/getSupplierCate
  40. * @method GET
  41. * @header name:Authorization require:1 desc:Token
  42. * @return name:id type:int default:-- desc:分类id
  43. * @return name:title type:string default:0 desc:分类名称
  44. * @return name:children type:array default:0 desc:下级分类
  45. */
  46. public function getSupplierCate()
  47. {
  48. $list = SupplierCate::where(['is_deleted'=>0])->field('id,title,pid')->order('sort desc')->select()->toArray();
  49. $list = make_tree($list);
  50. $this->success('ok',['list'=>$list]);
  51. }
  52. /**
  53. * @title 联系我们(详情内部)【两个二维码】
  54. * @desc 联系我们
  55. * @author qc
  56. * @method GET
  57. * @url /api/Supplier/getSupplierContact
  58. * @header name:Authorization require:1 desc:Token
  59. * @param name:supplier_id type:int default:-- desc:供应商id
  60. * @return name:phone type:string default:-- desc:供应商电话
  61. * @return name:email type:string default:-- desc:供应商email
  62. * @return name:qr_code type:int default:-- desc:供应商二维码
  63. * @return name:contact_qrcode type:string default:-- desc:平台二维码
  64. * @return name:contact_phone type:string default:-- desc:平台电话
  65. * @return name:contact_email type:string default:-- desc:平台邮箱
  66. */
  67. public function getSupplierContact()
  68. {
  69. $sel_where[] = ['id','=',input('get.supplier_id')];
  70. $detail = \app\common\model\Supplier::field('id,phone,email,qr_code')->where($sel_where)->find()->toArray();
  71. $contact = Db::name('contact')->where('tag','supplier')->field('qrcode contact_qrcode,phone contact_phone,email contact_email')->find();
  72. $contact['phone'] = $detail['phone'];
  73. $contact['email'] = $detail['email'];
  74. $contact['qr_code'] = $detail['qr_code'];;
  75. $this->success('ok',$contact);
  76. }
  77. /**
  78. * @title 获取供应商列表
  79. * @desc 获取供应商列表
  80. * @author qc
  81. * @method GET
  82. * @url /api/Supplier/getSupplierList
  83. * @header name:Authorization require:1 desc:Token
  84. * @param name:title type:string default:-- desc:标题
  85. * @param name:page type:int default:0 desc:页数
  86. * @param name:page_num type:int default:20 desc:每页数
  87. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  88. * @param name:first_classify type:int default:0 desc:一级分类id
  89. * @param name:second_classify type:int default:0 desc:二级分类id
  90. *
  91. * @return name:title type:string default:-- desc:名称
  92. * @return name:cover type:string default:-- desc:公司logo
  93. * @return name:phone type:string default:-- desc:电话
  94. * @return name:email type:string default:-- desc:email
  95. * @return name:label_name type:array default:-- desc:标签
  96. * @return name:content type:string default:-- desc:供应商详情
  97. * @return name:create_at type:string default:-- desc:时间
  98. * @return name:build_time type:string default:-- desc:成立时间
  99. * @return name:work_place type:string default:-- desc:办公地点
  100. * @return name:business type:string default:-- desc:业务范围
  101. *
  102. */
  103. public function getSupplierList(){
  104. $title = input('get.title');
  105. $sort_type = input('get.sort_type',1);
  106. $first_classify = input('get.first_classify');
  107. $second_classify = input('get.second_classify');
  108. switch ($sort_type) {
  109. case 1:
  110. $order = ['sort'=>'desc','id'=>'desc'];
  111. break;
  112. case 2:
  113. $order = ['id'=>'asc','sort'=>'desc'];
  114. break;
  115. case 3:
  116. $order = ['id'=>'desc','sort'=>'desc'];
  117. break;
  118. }
  119. $sel_where = [];
  120. $sel_where[] = ['is_deleted','=',0];
  121. $sel_where[] = ['status','=',1];
  122. if($first_classify) $sel_where[] = ['first_classify','=',$first_classify];
  123. if($second_classify) $sel_where[] = ['second_classify','=',$second_classify];
  124. if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,9);
  125. $list = \app\common\model\Supplier::where($sel_where)
  126. ->when($title,function ($query)use($title){
  127. if($title) $query->where('title|label','like','%'.$title.'%');
  128. })->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
  129. foreach ($list as &$v) {
  130. $v['cover'] =$v['logo'] ;
  131. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
  132. $v['business_arr'] = $v['business'] ? explode(',',trim($v['business'],',')) : null;
  133. }
  134. $this->success('ok',['list'=>$list]);
  135. }
  136. /**
  137. * @title 获取供应商详情
  138. * @desc 获取供应商详情
  139. * @author qc
  140. * @method GET
  141. * @url /api/Supplier/getSupplierDetail
  142. * @header name:Authorization require:1 desc:Token
  143. * @param name:id type:int default:-- desc:供应商记录id
  144. * @return name:title type:string default:-- desc:名称
  145. * @return name:cover type:string default:-- desc:公司logo
  146. * @return name:phone type:string default:-- desc:电话
  147. * @return name:email type:string default:-- desc:email
  148. * @return name:label_name type:array default:-- desc:标签
  149. * @return name:content type:string default:-- desc:供应商详情
  150. * @return name:create_at type:string default:-- desc:时间
  151. * @return name:build_time type:string default:-- desc:成立时间
  152. * @return name:work_place type:string default:-- desc:办公地点
  153. * @return name:business type:string default:-- desc:业务范围
  154. */
  155. public function getSupplierDetail()
  156. {
  157. $sel_where[] = ['id','=',input('get.id')];
  158. $detail = \app\common\model\Supplier::where($sel_where)->find()->toArray();
  159. $detail['label_name'] =$detail['label'] ? explode(',',trim($detail['label'],',')):null;
  160. $detail['business_arr'] = $detail['business'] ? explode(',',trim($detail['business'],',')) : null;
  161. UserTrack::crateTrack($this->user_id,9,input('get.id'),0);
  162. $this->success('ok',['detail'=>$detail]);
  163. }
  164. /**
  165. * @title 供应商商品推荐
  166. * @desc 供应商商品推荐
  167. * @author qc
  168. * @method GET
  169. * @url /api/Supplier/getRecommendList
  170. * @header name:Authorization require:1 desc:Token
  171. * @param name:page type:int default:0 desc:页数
  172. * @param name:page_num type:int default:20 desc:每页数
  173. * @return name:id type:int default:-- desc:供应商商品d
  174. * @return name:name type:string default:-- desc:商品名称
  175. * @return name:cover_arr type:array default:-- desc:封面
  176. * @return name:label_name type:array default:-- desc:标签
  177. * @return name:label type:string default:-- desc:标签
  178. * @return name:supplier_name type:float default:-- desc:供应商名称
  179. * @return name:supplier_logo type:string default:-- desc供应商logo
  180. * @return name:read_num type:int default:-- desc:阅读量
  181. *
  182. */
  183. public function getRecommendList()
  184. {
  185. $search_log = UserSearch::getSearchTitle($this->user_id,10);
  186. $search_arr = [];
  187. $where_str = 'b.id > 0';
  188. foreach ($search_log as $t){
  189. $search_arr[] = " b.name like '".'%'.$t."%'" .' ';
  190. $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
  191. }
  192. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  193. $field = 'a.id,a.supplier_id,a.name,a.label,a.cover,a.read_num,IFNULL(is_recommend,0) is_recommend ';
  194. $table = 'dd_supplier_goods';
  195. $order_by_two = 'read_num';
  196. $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id LEFT JOIN dd_supplier as k ON a.supplier_id = k.id WHERE a.is_deleted = 0 AND a.status = 1 AND k.status =1 AND k.is_deleted = 0 ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}";
  197. $list = Db::query($sql);
  198. array_walk($list,function (&$v,$k){
  199. $supplier_info =\app\common\model\Supplier::where('id',$v['supplier_id'])->find()->toArray();
  200. $v['supplier_name']=$supplier_info['title'];
  201. $v['supplier_logo'] =$supplier_info['logo'];
  202. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  203. $v['cover_arr'] = $v['cover']? explode('|',trim($v['cover'],'|')):null;
  204. });
  205. $this->success('ok',['list'=>$list]);
  206. }
  207. /**
  208. * @title 供应商商品列表【产品集合】
  209. * @desc 供应商商品列表
  210. * @author qc
  211. * @method GET
  212. * @url /api/Supplier/getSupplierGoodsList
  213. * @header name:Authorization require:1 desc:Token
  214. * @param name:supplier_id type:int default:-- desc:供应商记录id
  215. * @param name:page type:int default:0 desc:页数
  216. * @param name:page_num type:int default:20 desc:每页数
  217. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  218. *
  219. * @return name:name type:string default:-- desc:名称
  220. * @return name:supplier_name type:string default:-- desc:供应商名称
  221. * @return name:supplier_logo type:string default:-- desc供应商logo
  222. * @return name:cover type:string default:-- desc:图片【多张|隔开】
  223. * @return name:cover_arr type:array default:-- desc:图片数组
  224. * @return name:label_name type:array default:-- desc:标签
  225. * @return name:content type:string default:-- desc:详情
  226. * @return name:article_id type:int default:-- desc:关联图文id【单个id||系列id】
  227. * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
  228. * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
  229. * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
  230. * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
  231. * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  232. * @return name:total_num type:array default:-- desc:总数
  233. *
  234. */
  235. public function getSupplierGoodsList()
  236. {
  237. $supplier_id = input('get.supplier_id');
  238. $sort_type = input('get.sort_type',1);
  239. switch ($sort_type) {
  240. case 1:
  241. $order = ['sort'=>'desc','id'=>'desc'];
  242. break;
  243. case 2:
  244. $order = ['id'=>'asc','sort'=>'desc'];
  245. break;
  246. case 3:
  247. $order = ['id'=>'desc','sort'=>'desc'];
  248. break;
  249. }
  250. $sel_where = [];
  251. $sel_where[] = ['is_deleted','=',0];
  252. $sel_where[] = ['status','=',1];
  253. $sel_where[] = ['supplier_id','=',$supplier_id];
  254. $list = SupplierGoods::where($sel_where)
  255. ->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
  256. $supplier_info = \app\common\model\Supplier::where('id',$supplier_id)->find()->toArray();
  257. foreach ($list as &$v) {
  258. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
  259. $v['cover_arr'] =$v['cover'] ? explode('|',trim($v['cover'])):null;
  260. $v['supplier_name'] =$supplier_info['title'];
  261. $v['supplier_logo'] =$supplier_info['logo'];
  262. }
  263. $total_num = SupplierGoods::where($sel_where)->count();
  264. $this->success('ok',['list'=>$list,'total_num'=>$total_num]);
  265. }
  266. /**
  267. * @title 供应商产品详情
  268. * @desc 供应商产品详情
  269. * @author qc
  270. * @method GET
  271. * @url /api/Supplier/getSupplierGoodsDetail
  272. * @header name:Authorization require:1 desc:Token
  273. * @param name:goods_id type:int default:-- desc:供应商产品id
  274. * @return name:name type:string default:-- desc:名称
  275. * @return name:cover type:string default:-- desc:图片【多张逗号隔开】
  276. * @return name:cover_arr type:array default:-- desc:图片数组
  277. * @return name:label_name type:array default:-- desc:标签
  278. * @return name:content type:string default:-- desc:详情
  279. * @return name:article_id type:int default:-- desc:关联图文id【单个id||系列id】
  280. * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
  281. * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
  282. * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
  283. * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
  284. * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  285. * @return name:is_collect type:int default:-- desc:是否收藏
  286. * @return name:collect_num type:int default:-- desc:收藏量
  287. * @return name:praise_num type:int default:-- desc:点赞量
  288. * @return name:is_praise type:int default:-- desc:是否点赞
  289. * @return name:transmit_num type:int default:-- desc:转发量
  290. *
  291. * @return name:supplier_info type:array default:-- desc:供应商详情
  292. * @return name:supplier_info.title type:string default:-- desc:名称
  293. * @return name:supplier_info.cover type:string default:-- desc:公司logo
  294. * @return name:supplier_info.phone type:string default:-- desc:电话
  295. * @return name:supplier_info.email type:string default:-- desc:email
  296. * @return name:supplier_info.label_name type:array default:-- desc:标签
  297. * @return name:supplier_info.content type:string default:-- desc:供应商详情
  298. * @return name:supplier_info.create_at type:string default:-- desc:时间
  299. * @return name:supplier_info.build_time type:string default:-- desc:成立时间
  300. * @return name:supplier_info.work_place type:string default:-- desc:办公地点
  301. * @return name:supplier_info.business type:string default:-- desc:业务范围
  302. */
  303. public function getSupplierGoodsDetail()
  304. {
  305. $goods_id = input('get.goods_id');
  306. $detail = SupplierGoods::where('id',$goods_id)->find()->toArray();
  307. $detail['label_name'] =$detail['label'] ? explode(',',trim($detail['label'],',')):null;
  308. $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,9,$detail['id']);
  309. $detail['collect_num'] = UserCollect::getCollectNum(9,$detail['id']);
  310. $detail['is_praise'] = PlatformLike::checkTags($this->user_id,$detail['id'],7);
  311. $detail['praise_num'] = PlatformLike::getPraiseNum($detail['id'],7);
  312. $supplier_info = \app\common\model\Supplier::where('id',$detail['supplier_id'])->find()->toArray();
  313. $supplier_info['label_name'] =$supplier_info['label'] ? explode(',',trim($supplier_info['label'],',')):null;
  314. $supplier_info['business_arr'] = $supplier_info['business'] ? explode(',',trim($supplier_info['business'],',')) : null;
  315. $supplier_info['cover'] = $supplier_info['logo'] ;
  316. UserTrack::crateTrack($this->user_id,10,$goods_id,0);
  317. SupplierGoods::where('id',$goods_id)->setInc('read_num');
  318. $this->success('ok',['detail'=>$detail,'supplier_info'=>$supplier_info]);
  319. }
  320. /**
  321. * @title 供应商搜索列表
  322. * @desc 供应商搜索列表
  323. * @author qc
  324. * @method GET
  325. * @url /api/Supplier/searchGoods
  326. * @header name:Authorization require:1 desc:Token
  327. * @param name:search_name type:int default:-- desc:搜索名称
  328. * @param name:page type:int default:0 desc:页数
  329. * @param name:page_num type:int default:20 desc:每页数
  330. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  331. *
  332. * @return name:name type:string default:-- desc:名称
  333. * @return name:supplier_name type:string default:-- desc:供应商名称
  334. * @return name:cover type:string default:-- desc:图片【多张逗号隔开】
  335. * @return name:cover_arr type:array default:-- desc:图片数组
  336. * @return name:label_name type:array default:-- desc:标签
  337. * @return name:content type:string default:-- desc:详情
  338. * @return name:article_id type:int default:-- desc:关联图文id【单个id||系列id】
  339. * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
  340. * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
  341. * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
  342. * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
  343. * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  344. * @return name:total_num type:array default:-- desc:总数
  345. *
  346. */
  347. public function searchGoods()
  348. {
  349. $search_name = input('get.search_name');
  350. $sort_type = input('get.sort_type',1);
  351. switch ($sort_type) {
  352. case 1:
  353. $order = ['g.sort'=>'desc','g.id'=>'desc'];
  354. break;
  355. case 2:
  356. $order = ['g.id'=>'asc','g.sort'=>'desc'];
  357. break;
  358. case 3:
  359. $order = ['g.id'=>'g.desc','g.sort'=>'desc'];
  360. break;
  361. }
  362. $sel_where = [];
  363. $sel_where[] = ['g.is_deleted','=',0];
  364. $sel_where[] = ['g.status','=',1];
  365. if($search_name && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$search_name,10);
  366. $list = SupplierGoods::where($sel_where)
  367. ->field('g.id,g.supplier_id,g.name,g.label,g.cover,s.title supplier_name')
  368. ->when($search_name,function ($query)use($search_name){
  369. if($search_name) $query->where('g.name|g.label','like','%'.$search_name.'%');
  370. })->alias('g')
  371. ->leftJoin('Supplier s','g.supplier_id = s.id')
  372. ->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
  373. foreach ($list as &$v) {
  374. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
  375. $v['cover_arr'] =$v['cover'] ? explode('|',trim($v['cover'])):null;
  376. }
  377. $total_num = SupplierGoods::where($sel_where)->alias('g')->when($search_name,function ($query)use($search_name){
  378. if($search_name) $query->where('g.name|g.label','like','%'.$search_name.'%');
  379. })->count();
  380. $this->success('ok',['list'=>$list,'total_num'=>$total_num]);
  381. }
  382. /**
  383. * @title 以下接口调用验证登录【需要header传Authorization】
  384. * @desc 以下接口调用验证登录
  385. * @author qc
  386. * @method
  387. * @url /api/Supplier/needLogin()
  388. */
  389. public function needLogin(){}
  390. /**
  391. * @title 供应商商品点赞||取消点赞
  392. * @desc 点赞||取消点赞
  393. * @author qc
  394. * @method POST
  395. * @url /api/Supplier/supplierGoodsTags
  396. * @header name:Authorization require:1 desc:Token
  397. * @param name:id type:int default:1 desc:供应商商品记录id
  398. * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
  399. */
  400. public function supplierGoodsTags()
  401. {
  402. $ret_val = PlatformLike::userTags($this->user_id,input('post.id'),7);
  403. $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
  404. }
  405. /**
  406. * @title 供应商商品收藏||取消收藏
  407. * @desc 用户收藏
  408. * @author qc
  409. * @method POST
  410. * @url /api/Supplier/supplierGoodsCollect
  411. * @header name:Authorization require:1 desc:Token
  412. * @param name:id type:int require:1 default:-- desc:供应商商品记录id
  413. * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
  414. */
  415. public function supplierGoodsCollect(){
  416. $coll_status = UserCollect::plateCollect($this->user_id,9,input('post.id',0));
  417. $coll_status ? $this->success('收藏成功',['status'=>1]) : $this->success('取消收藏成功',['status'=>0]);
  418. }
  419. /**
  420. * @title 转发(转发数量统计【供应商】)
  421. * @desc 转发成功后调用
  422. * @author qc
  423. * @method POST
  424. * @url /api/Supplier/supplierTransmit
  425. * @header name:Authorization require:1 desc:Token
  426. * @param name:id type:int default:-- desc:供应商记录id
  427. */
  428. public function supplierTransmit()
  429. {
  430. $id = input('post.id',0);
  431. \app\common\model\Supplier::where('id',$id)->setInc('transmit_num');
  432. $this->success('ok');
  433. }
  434. /**
  435. * @title 转发(转发数量统计【供应商商品】)
  436. * @desc 转发成功后调用
  437. * @author qc
  438. * @method POST
  439. * @url /api/Supplier/supplierGoodsTransmit
  440. * @header name:Authorization require:1 desc:Token
  441. * @param name:id type:int default:-- desc:供应商商品记录id
  442. */
  443. public function supplierGoodsTransmit()
  444. {
  445. $id = input('post.id',0);
  446. SupplierGoods::where('id',$id)->setInc('transmit_num');
  447. $this->success('ok');
  448. }
  449. /**
  450. * @title 我的浏览历史【供应商商品】
  451. * @desc 我的浏览历史
  452. * @author qc
  453. * @method GET
  454. * @url /api/Supplier/getSupplierGoodsTrack
  455. * @header name:Authorization require:1 desc:Token
  456. * @param name:name type:string default:-- desc:商品名称
  457. * @param name:page type:int default:-- desc:页数
  458. * @param name:page_num type:int default:-- desc:每页数
  459. * @return name:id type:string default:-- desc:浏览记录id
  460. * @return name:goods_id type:string default:-- desc:商品id
  461. * @return name:name type:string default:-- desc:名称
  462. * @return name:cover type:string default:-- desc:封面(多张|隔开)
  463. * @return name:cover_arr type:array default:-- desc:封面
  464. * @return name:label_name type:array default:-- desc:标签
  465. * @return name:supplier_name type:array default:-- desc:供应商名称
  466. * @return name:time type:string default:-- desc:时间
  467. */
  468. public function getSupplierGoodsTrack()
  469. {
  470. $sel_where = [];
  471. $sel_where[] = ['t.user_id','=',$this->user_id];
  472. $sel_where[] = ['t.type','=',10];
  473. $name = input('get.name');
  474. if($name) $sel_where[] = ['i.name|i.label','like','%'.$name.'%'];
  475. $list = UserTrack::where($sel_where)
  476. ->alias('t')
  477. ->field('t.id,t.update_int,t.first_id goods_id,i.name,i.cover,i.label,supplier_id')
  478. ->leftJoin('SupplierGoods i','t.first_id = i.id')
  479. ->order('update_int desc')
  480. ->limit($this->off_set,$this->page_num)
  481. ->select()->toArray();
  482. foreach ($list as &$v) {
  483. $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
  484. $v['cover_arr'] = $v['cover']? explode('|',$v['cover']) : null;
  485. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  486. $v['supplier_name'] = \app\common\model\Supplier::where('id',$v['supplier_id'])->value('title');
  487. }
  488. $this->success('ok',['list'=>$list]);
  489. }
  490. /**
  491. * @title 我的点赞【供应商商品点赞列表】
  492. * @desc 供应商商品点赞列表
  493. * @author qc
  494. * @method GET
  495. * @url /api/Supplier/getTagsSupplierGoods
  496. * @header name:Authorization require:1 desc:Token
  497. * @param name:name type:string default:-- desc:商品名称
  498. * @param name:page type:int default:-- desc:页数
  499. * @param name:page_num type:int default:-- desc:每页数
  500. * @return name:id type:string default:-- desc:浏览记录id
  501. * @return name:goods_id type:string default:-- desc:商品id
  502. * @return name:name type:string default:-- desc:名称
  503. * @return name:cover type:string default:-- desc:封面(多张|隔开)
  504. * @return name:cover_arr type:array default:-- desc:封面
  505. * @return name:label_name type:array default:-- desc:标签
  506. * @return name:supplier_name type:array default:-- desc:供应商名称
  507. * @return name:create_at type:string default:-- desc:时间
  508. */
  509. public function getTagsSupplierGoods()
  510. {
  511. $sel_where = [];
  512. $name = input('get.name');
  513. if($name) $sel_where[] = ['i.name|i.label','like','%'.$name.'%'];
  514. $sel_where[] = ['t.user_id','=',$this->user_id];
  515. $sel_where[] = ['t.type','=',7];
  516. $list = PlatformLike::where($sel_where)
  517. ->alias('t')
  518. ->field('t.id,t.create_at,t.like_id goods_id,i.name,i.cover,i.label,supplier_id')
  519. ->leftJoin('SupplierGoods i','t.like_id = i.id')
  520. ->order('id desc')
  521. ->limit($this->off_set,$this->page_num)
  522. ->select()->toArray();
  523. foreach ($list as &$v) {
  524. $v['cover_arr'] = explode('|',$v['cover']);
  525. $v['label_name'] = explode(',',$v['label']);
  526. $v['supplier_name'] = \app\common\model\Supplier::where('id',$v['supplier_id'])->value('title');
  527. }
  528. $this->success('ok',['list'=>$list]);
  529. }
  530. /**
  531. * @title 我的收藏【供应商商品收藏列表】
  532. * @desc 供应商商品收藏列表
  533. * @author qc
  534. * @method GET
  535. * @url /api/Supplier/getCollectSupplierGoods
  536. * @header name:Authorization require:1 desc:Token
  537. * @param name:name type:string default:-- desc:商品名称
  538. * @param name:page type:int default:-- desc:页数
  539. * @param name:page_num type:int default:-- desc:每页数
  540. *
  541. * @return name:id type:string default:-- desc:浏览记录id
  542. * @return name:goods_id type:string default:-- desc:商品id
  543. * @return name:name type:string default:-- desc:名称
  544. * @return name:cover type:string default:-- desc:封面(多张|隔开)
  545. * @return name:cover_arr type:array default:-- desc:封面
  546. * @return name:label_name type:array default:-- desc:标签
  547. * @return name:supplier_name type:array default:-- desc:供应商名称
  548. * @return name:create_at type:string default:-- desc:时间
  549. */
  550. public function getCollectSupplierGoods()
  551. {
  552. $sel_where = [];
  553. $name = input('get.name');
  554. if($name) $sel_where[] = ['i.name|i.label','like','%'.$name.'%'];
  555. $sel_where[] = ['t.user_id','=',$this->user_id];
  556. $sel_where[] = ['t.coll_type','=',9];
  557. $list = UserCollect::where($sel_where)
  558. ->alias('t')
  559. ->field('t.id,t.create_at,t.coll_id goods_id,i.name,i.cover,i.label,supplier_id')
  560. ->leftJoin('SupplierGoods i','t.coll_id = i.id')
  561. ->order('id desc')
  562. ->limit($this->off_set,$this->page_num)
  563. ->select()->toArray();
  564. foreach ($list as &$v) {
  565. $v['cover_arr'] = explode('|',$v['cover']);
  566. $v['label_name'] = explode(',',$v['label']);
  567. $v['supplier_name'] = \app\common\model\Supplier::where('id',$v['supplier_id'])->value('title');
  568. }
  569. $this->success('ok',['list'=>$list]);
  570. }
  571. }