Supplier.php 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\ArticleItem;
  4. use app\common\model\DatumUrl;
  5. use app\common\model\PlatformLike;
  6. use app\common\model\PlatformSwitch;
  7. use app\common\model\SupplierCate;
  8. use app\common\model\SupplierComment;
  9. use app\common\model\TopSearch;
  10. use app\common\model\UserCollect;
  11. use app\common\model\UserMessage;
  12. use app\common\model\UserSearch;
  13. use app\common\model\SupplierGoods;
  14. use app\common\model\UserTrack;
  15. use app\common\model\VideoUrl;
  16. use app\common\service\CheckPower;
  17. use app\common\service\UserSynth;
  18. use think\Db;
  19. /**
  20. * @title 供应商
  21. * @controller Supplier
  22. * @group base
  23. */
  24. class Supplier extends Base
  25. {
  26. // 需要登录的
  27. protected $need_login = [
  28. 'firstComment',
  29. 'secondComment',
  30. 'supplierTags',
  31. 'supplierGoodsCollect',
  32. 'getSupplierGoodsTrack',
  33. 'supplierTransmit',
  34. 'getSupplierGoodsTrack',
  35. 'getTagsSupplierGoods',
  36. 'getTagsComment',
  37. 'getCollectSupplierGoods',
  38. 'getFollowUpList',
  39. 'praiseGoodsList',
  40. 'praiseCommentList',
  41. 'getMyGoodsList',
  42. 'commentOnMyGoods',
  43. 'getReplayComment',
  44. ];
  45. public function initialize()
  46. {
  47. parent::initialize();
  48. parent::setUid();
  49. }
  50. /**
  51. * @title 供应商接口说明
  52. * @desc 供应商接口说明
  53. * @author qc
  54. * @url /api/Supplier/classIntro
  55. * @method GET
  56. * @return name:1 type:string default:-- desc:--
  57. */
  58. public function classIntro(){}
  59. /**
  60. * @title 获取供应商分类
  61. * @desc 三级分类
  62. * @author qc
  63. * @url /api/Supplier/getSupplierCate
  64. * @method GET
  65. * @header name:Authorization require:1 desc:Token
  66. * @return name:id type:int default:-- desc:分类id
  67. * @return name:title type:string default:0 desc:分类名称
  68. * @return name:lev type:int default:0 desc:分类等级
  69. * @return name:children type:array default:0 desc:下级分类
  70. */
  71. public function getSupplierCate()
  72. {
  73. $list = SupplierCate::where(['is_deleted'=>0])->field('id,title,pid,lev,logo')->order('sort desc,id asc')->select()->toArray();
  74. $list = make_tree($list);
  75. $this->success('ok',['list'=>$list]);
  76. }
  77. /**
  78. * @title 获取第三级分类
  79. * @desc 获取第三级分类
  80. * @author qc
  81. * @url /api/Supplier/getThirdCate
  82. * @method GET
  83. * @header name:Authorization require:1 desc:Token
  84. * @param name:fid type:int default:-- desc:一级分类id
  85. * @param name:pid type:int default:-- desc:二级分类id【不传查一级分类下全部的三级分类】
  86. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  87. * @return name:id type:int default:-- desc:分类id
  88. * @return name:title type:string default:0 desc:分类名称
  89. * @return name:lev type:int default:0 desc:分类等级
  90. * @return name:children type:array default:0 desc:下级分类
  91. */
  92. public function getThirdCate()
  93. {
  94. $where = [];
  95. $where[]=['is_deleted','=',0];
  96. $where[]=['pid','=',input('fid')];
  97. $sort_type = input('get.sort_type',1);
  98. if(!$sort_type){
  99. $order = ['sort desc,id asc'];
  100. }
  101. switch ($sort_type) {
  102. case 1:
  103. $order = 'sort desc,id asc';
  104. break;
  105. case 2:
  106. $order = 'id asc,sort desc';
  107. break;
  108. case 3:
  109. $order = 'id desc,sort desc';
  110. break;
  111. }
  112. if(input('pid')) $where[] = ['id','=',input('pid')];
  113. $list = SupplierCate::where($where)->field('id,title,pid,lev,logo')->order('sort desc,id asc')->select()->toArray();
  114. foreach ($list as &$v) {
  115. $v['children'] = SupplierCate::where([['is_deleted','=',0],['pid','=',$v['id']]])->field('id,title,pid,lev,logo')->order($order)->select()->toArray();
  116. }
  117. $this->success('ok',['list'=>$list]);
  118. }
  119. /**
  120. * @title 联系我们(详情内部)【两个二维码】
  121. * @desc 联系我们
  122. * @author qc
  123. * @method GET
  124. * @url /api/Supplier/getSupplierContact
  125. * @header name:Authorization require:1 desc:Token
  126. * @param name:supplier_id type:int default:-- desc:供应商id
  127. * @return name:phone type:string default:-- desc:供应商电话
  128. * @return name:email type:string default:-- desc:供应商email
  129. * @return name:qr_code type:int default:-- desc:供应商二维码
  130. * @return name:contact_qrcode type:string default:-- desc:平台二维码
  131. * @return name:contact_phone type:string default:-- desc:平台电话
  132. * @return name:contact_email type:string default:-- desc:平台邮箱
  133. */
  134. public function getSupplierContact()
  135. {
  136. $sel_where[] = ['id','=',input('get.supplier_id')];
  137. $detail = \app\common\model\Supplier::field('id,phone,email,qr_code')->where($sel_where)->find()->toArray();
  138. $contact = Db::name('contact')->where('tag','supplier')->field('qrcode contact_qrcode,phone contact_phone,email contact_email')->find();
  139. $contact['phone'] = $detail['phone'];
  140. $contact['email'] = $detail['email'];
  141. $contact['qr_code'] = $detail['qr_code'];
  142. $this->success('ok',$contact);
  143. }
  144. /**
  145. * @title 获取供应商列表
  146. * @desc 获取供应商列表
  147. * @author qc
  148. * @method GET
  149. * @url /api/Supplier/getSupplierList
  150. * @header name:Authorization require:1 desc:Token
  151. * @param name:title type:string default:-- desc:标题
  152. * @param name:page type:int default:0 desc:页数
  153. * @param name:page_num type:int default:20 desc:每页数
  154. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  155. * @return name:title type:string default:-- desc:名称
  156. * @return name:cover type:string default:-- desc:公司logo
  157. * @return name:phone type:string default:-- desc:电话
  158. * @return name:email type:string default:-- desc:email
  159. * @return name:label_name type:array default:-- desc:标签
  160. * @return name:content type:string default:-- desc:供应商详情
  161. * @return name:create_at type:string default:-- desc:时间
  162. * @return name:build_time type:string default:-- desc:成立时间
  163. * @return name:work_place type:string default:-- desc:办公地点
  164. * @return name:business type:string default:-- desc:业务范围
  165. * @return name:total_num type:int default:-- desc:总评论数(仅一级)
  166. */
  167. public function getSupplierList(){
  168. $title = input('get.title');
  169. $sort_type = input('get.sort_type',1);
  170. switch ($sort_type) {
  171. case 1:
  172. $order = ['sort'=>'desc','id'=>'asc'];
  173. break;
  174. case 2:
  175. $order = ['id'=>'asc','sort'=>'desc'];
  176. break;
  177. case 3:
  178. $order = ['id'=>'desc','sort'=>'desc'];
  179. break;
  180. }
  181. $sel_where = [];
  182. $sel_where[] = ['is_deleted','=',0];
  183. $sel_where[] = ['status','=',1];
  184. if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,9);
  185. $list = \app\common\model\Supplier::where($sel_where)
  186. ->when($title,function ($query)use($title){
  187. if($title) $query->where('title|label','like','%'.$title.'%');
  188. })->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
  189. foreach ($list as &$v) {
  190. $v['cover'] =$v['logo'] ;
  191. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
  192. $v['business_arr'] = $v['business'] ? explode(',',trim($v['business'],',')) : null;
  193. }
  194. $total_num =\app\common\model\Supplier::where($sel_where)->when($title,function ($query)use($title){
  195. if($title) $query->where('title|label','like','%'.$title.'%');
  196. })->count();
  197. $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
  198. }
  199. /**
  200. * @title 获取供应商详情
  201. * @desc 获取供应商详情
  202. * @author qc
  203. * @method GET
  204. * @url /api/Supplier/getSupplierDetail
  205. * @header name:Authorization require:1 desc:Token
  206. * @param name:id type:int default:-- desc:供应商记录id
  207. * @return name:title type:string default:-- desc:名称
  208. * @return name:cover type:string default:-- desc:公司logo
  209. * @return name:phone type:string default:-- desc:电话
  210. * @return name:email type:string default:-- desc:email
  211. * @return name:label_name type:array default:-- desc:标签
  212. * @return name:content type:string default:-- desc:供应商详情
  213. * @return name:create_at type:string default:-- desc:时间
  214. * @return name:build_time type:string default:-- desc:成立时间
  215. * @return name:work_place type:string default:-- desc:办公地点
  216. * @return name:business type:string default:-- desc:业务范围
  217. */
  218. public function getSupplierDetail()
  219. {
  220. $sel_where[] = ['id','=',input('get.id')];
  221. $detail = \app\common\model\Supplier::where($sel_where)->find()->toArray();
  222. $detail['label_name'] =$detail['label'] ? explode(',',trim($detail['label'],',')):null;
  223. $detail['business_arr'] = $detail['business'] ? explode(',',trim($detail['business'],',')) : null;
  224. UserTrack::crateTrack($this->user_id,9,input('get.id'),0);
  225. $this->success('ok',['detail'=>$detail]);
  226. }
  227. /**
  228. * @title 供应商产品推荐
  229. * @desc 供应商产品推荐
  230. * @author qc
  231. * @method GET
  232. * @url /api/Supplier/getRecommendList
  233. * @header name:Authorization require:1 desc:Token
  234. * @param name:page type:int default:0 desc:页数
  235. * @param name:page_num type:int default:20 desc:每页数
  236. * @param name:rand_user type:string default:-- desc:随机id(非登录状态必传,page=1时生成(a123),其他页数(a123),一直查询到没有数据)
  237. * @return name:id type:int default:-- desc:供应商产品d
  238. * @return name:name type:string default:-- desc:产品名称
  239. * @return name:cover_arr type:array default:-- desc:封面
  240. * @return name:label_name type:array default:-- desc:标签
  241. * @return name:label type:string default:-- desc:标签
  242. * @return name:supplier_name type:float default:-- desc:供应商名称
  243. * @return name:supplier_logo type:string default:-- desc供应商logo
  244. * @return name:read_num type:int default:-- desc:浏览量
  245. * @return name:release_time type:string default:-- desc:上架时间
  246. *
  247. */
  248. public function getRecommendList()
  249. {
  250. $user_id = $this->user_id ? $this->user_id : input('rand_user');
  251. if(!$user_id) $this->error('参数错误');
  252. $list = UserSynth::getRecommendList($user_id,'supplier',$this->page,$this->page_num,[],input('sort_type',1));
  253. if($list['code'] != 200) $this->error($list['msg']);
  254. $this->success('ok',$list);
  255. $search_log = UserSearch::getSearchTitle($this->user_id,10);
  256. $search_arr = [];
  257. $where_str = 'b.id > 0';
  258. foreach ($search_log as $t){
  259. $search_arr[] = " b.name like '".'%'.$t."%'" .' ';
  260. $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
  261. }
  262. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  263. $field = 'a.id,a.supplier_id,a.name,a.label,a.cover,a.read_num,IFNULL(is_recommend,0) is_recommend ,k.title supplier_name,k.logo supplier_logo';
  264. $table = 'dd_supplier_goods';
  265. $order_by_two = 'a.read_num';
  266. $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}";
  267. $list = Db::query($sql);
  268. $list = dispose_recommend($list);
  269. array_walk($list,function (&$v,$k){
  270. /* $supplier_info =\app\common\model\Supplier::where('id',$v['supplier_id'])->find()->toArray();
  271. $v['supplier_name']=$supplier_info['title'];
  272. $v['supplier_logo'] =$supplier_info['logo'];*/
  273. $v['read_num'] = numTransform($v['read_num']);
  274. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  275. $v['cover_arr'] = $v['cover']? explode('|',trim($v['cover'],'|')):null;
  276. });
  277. $sql2 = "SELECT count(a.id) num 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 ";
  278. $total = Db::query($sql2);
  279. $this->success('ok',['list'=>$list,'total_count'=>$total[0]['num'],'page_num'=>$this->page_num]);
  280. }
  281. /**
  282. * @title 合集列表--【按分类查询】
  283. * @desc 按供应商查询
  284. * @author qc
  285. * @method GET
  286. * @url /api/Supplier/getGoodsListByClassify
  287. * @header name:Authorization require:1 desc:Token
  288. * @param name:third_classify type:int default:-- desc:分类id【第三级】
  289. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  290. * @return name:name type:string default:-- desc:名称
  291. * @return name:supplier_name type:string default:-- desc:供应商名称
  292. * @return name:supplier_logo type:string default:-- desc供应商logo
  293. * @return name:cover type:string default:-- desc:图片【多张|隔开】
  294. * @return name:cover_arr type:array default:-- desc:图片数组
  295. * @return name:label_name type:array default:-- desc:标签
  296. * @return name:release_time type:string default:-- desc:上架时间
  297. * @return name:total_num type:array default:-- desc:总数
  298. *
  299. */
  300. public function getGoodsListByClassify()
  301. {
  302. $third_classify = input('get.third_classify');
  303. $sel_where = [];
  304. $sel_where[] = ['g.is_deleted','=',0];
  305. $sel_where[] = ['g.status','=',1];
  306. $sel_where[] = ['g.third_classify','=',$third_classify];
  307. $sort_type = input('get.sort_type',1);
  308. switch ($sort_type) {
  309. case 1:
  310. $order = ['g.sort'=>'desc','g.id'=>'desc'];
  311. break;
  312. case 2:
  313. $order = ['g.id'=>'asc'];
  314. break;
  315. case 3:
  316. $order = ['g.id'=>'desc'];
  317. break;
  318. }
  319. $list = SupplierGoods::where($sel_where)
  320. ->alias('g')
  321. ->field('g.id,g.label,g.cover,g.name,g.read_num,s.title supplier_name,s.logo supplier_logo,release_time')
  322. ->leftJoin('Supplier s','s.id = g.supplier_id')
  323. ->order($order)
  324. ->select()->toArray();
  325. foreach ($list as &$v) {
  326. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
  327. $v['cover_arr'] =$v['cover'] ? explode('|',trim($v['cover'])):null;
  328. }
  329. $total_num = SupplierGoods::where($sel_where)->alias('g')->count();
  330. $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
  331. }
  332. /**
  333. * @title 合集列表--【按供应商查询】
  334. * @desc 按供应商查询
  335. * @author qc
  336. * @method GET
  337. * @url /api/Supplier/getSupplierGoodsList
  338. * @header name:Authorization require:1 desc:Token
  339. * @param name:supplier_id type:int default:-- desc:供应商记录id
  340. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  341. * @return name:name type:string default:-- desc:名称
  342. * @return name:supplier_name type:string default:-- desc:供应商名称
  343. * @return name:supplier_logo type:string default:-- desc供应商logo
  344. * @return name:cover type:string default:-- desc:图片【多张|隔开】
  345. * @return name:cover_arr type:array default:-- desc:图片数组
  346. * @return name:label_name type:array default:-- desc:标签
  347. * @return name:release_time type:string default:-- desc:上架时间
  348. * @return name:is_recently type:int default:-- desc:是否最近观看【0否1是】
  349. * @return name:supplier_info type:array default:-- desc:供应商信息
  350. * @return name:supplier_info.id type:int default:-- desc:供应商id
  351. * @return name:supplier_info.title type:int default:-- desc:名称
  352. * @return name:supplier_info.follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
  353. *
  354. */
  355. public function getSupplierGoodsList()
  356. {
  357. $supplier_id = input('get.supplier_id');
  358. $sort_type = input('get.sort_type',1);
  359. switch ($sort_type) {
  360. case 1:
  361. $order = ['sort'=>'desc','read_num'=>'desc','id'=>'asc'];
  362. break;
  363. case 2:
  364. $order = ['id'=>'asc','sort'=>'desc'];
  365. break;
  366. case 3:
  367. $order = ['id'=>'desc','sort'=>'desc'];
  368. break;
  369. }
  370. $sel_where = [];
  371. $sel_where[] = ['is_deleted','=',0];
  372. $sel_where[] = ['status','=',1];
  373. $sel_where[] = ['supplier_id','=',$supplier_id];
  374. $list = SupplierGoods::where($sel_where)
  375. ->field('id,name,label,cover,create_at,read_num,release_time')
  376. ->order($order)->select()->toArray();
  377. $supplier_info = \app\common\model\Supplier::where('id',$supplier_id)->field('id,title,logo')->find()->toArray();
  378. $supplier_info['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$supplier_id,5);
  379. foreach ($list as &$v) {
  380. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
  381. $v['cover_arr'] =$v['cover'] ? explode('|',trim($v['cover'])):null;
  382. $v['read_num'] = numTransform($v['read_num']);
  383. $v['create_at'] = substr($v['create_at'],0,10);
  384. $recently_id = UserTrack::getRecentlyTrack($this->user_id,10,$v['id']);
  385. $v['is_recently'] = $recently_id ? 1:0;
  386. }
  387. $total_num = SupplierGoods::where($sel_where)->count();
  388. $this->success('ok',['list'=>$list,'supplier_info'=>$supplier_info,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
  389. }
  390. /**
  391. * @title 产品详情--【ui是供应商详情】
  392. * @desc 产品详情
  393. * @author qc
  394. * @method GET
  395. * @url /api/Supplier/getSupplierGoodsDetail
  396. * @header name:Authorization require:1 desc:Token
  397. * @param name:goods_id type:int default:-- desc:供应商产品id
  398. * @return name:name type:string default:-- desc:名称
  399. * @return name:cover type:string default:-- desc:图片【多张逗号隔开】
  400. * @return name:cover_arr type:array default:-- desc:图片数组
  401. * @return name:label_name type:array default:-- desc:标签
  402. * @return name:content type:string default:-- desc:详情
  403. * @return name:article_id type:int default:-- desc:关联图文id【单个id||系列id】
  404. * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
  405. * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
  406. * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
  407. * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
  408. * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  409. * @return name:is_collect type:int default:-- desc:是否收藏
  410. * @return name:collect_num type:int default:-- desc:收藏量
  411. * @return name:comment_num type:int default:-- desc:评论量
  412. * @return name:praise_num type:int default:-- desc:点赞量
  413. * @return name:is_praise type:int default:-- desc:是否点赞
  414. * @return name:transmit_num type:int default:-- desc:转发量
  415. * @return name:release_time type:string default:-- desc:上架时间
  416. * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
  417. * @return name:article_jump type:int default:-- desc:关联图文是否能跳转【0不能跳转,1能跳转,验证是否vip】
  418. * @return name:datum_jump type:int default:-- desc:关联资料是否能跳转【0不能跳转,1能跳转,验证是否vip】
  419. * @return name:video_jump type:int default:-- desc:关联视频是否能跳转【0不能跳转,1能跳转,验证是否vip】
  420. * @return name:supplier_info type:array default:-- desc:供应商详情
  421. * @return name:supplier_info.title type:string default:-- desc:名称
  422. * @return name:supplier_info.cover type:string default:-- desc:公司logo
  423. * @return name:supplier_info.phone type:string default:-- desc:电话
  424. * @return name:supplier_info.email type:string default:-- desc:email
  425. * @return name:supplier_info.label_name type:array default:-- desc:标签
  426. * @return name:supplier_info.content type:string default:-- desc:供应商详情
  427. * @return name:supplier_info.create_at type:string default:-- desc:时间
  428. * @return name:supplier_info.build_time type:string default:-- desc:成立时间
  429. * @return name:supplier_info.work_place type:string default:-- desc:办公地点
  430. * @return name:supplier_info.business type:string default:-- desc:业务范围
  431. * @return name:supplier_info.follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
  432. */
  433. public function getSupplierGoodsDetail()
  434. {
  435. $goods_id = input('get.goods_id');
  436. $detail = SupplierGoods::where('id',$goods_id)->find()->toArray();
  437. $detail['label_name'] =$detail['label'] ? explode(',',trim($detail['label'],',')):null;
  438. $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,9,$detail['id']);
  439. $detail['collect_num'] = UserCollect::getCollectNum(9,$detail['id']);
  440. $detail['is_praise'] = PlatformLike::checkTags($this->user_id,$detail['id'],7);
  441. $detail['praise_num'] = PlatformLike::getPraiseNum($detail['id'],7);
  442. $detail['read_num'] = numTransform($detail['read_num']);
  443. $detail['transmit_num'] = numTransform($detail['transmit_num']);
  444. $detail['comment_num'] = SupplierComment::getCommentNum($detail['id']);
  445. $detail['video_vip'] = numTransform($detail['transmit_num']);
  446. $detail['article_jump'] = ArticleItem::checkVip($detail['article_item'],$this->user_id);
  447. $detail['datum_jump'] = DatumUrl::checkVip($detail['datum_item'],$this->user_id);
  448. $detail['video_jump'] = VideoUrl::checkVip($detail['video_item'],$this->user_id);
  449. $detail['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],11);
  450. $supplier_info = \app\common\model\Supplier::where('id',$detail['supplier_id'])->find();
  451. if($supplier_info){
  452. $supplier_info['label_name'] =$supplier_info['label'] ? explode(',',trim($supplier_info['label'],',')):null;
  453. $supplier_info['business_arr'] = $supplier_info['business'] ? explode(',',trim($supplier_info['business'],',')) : null;
  454. $supplier_info['cover'] = $supplier_info['logo'] ;
  455. $supplier_info['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$detail['supplier_id'],5);
  456. }
  457. UserTrack::crateTrack($this->user_id,10,$goods_id,0);
  458. SupplierGoods::where('id',$goods_id)->setInc('read_num');
  459. if($this->user_id){
  460. TopSearch::seIncHotNum($detail['id'],'supplier_goods');
  461. }
  462. if($this->user_id){
  463. $General = new General();
  464. $General->label($detail['label']);
  465. }
  466. $this->success('ok',['detail'=>$detail,'supplier_info'=>$supplier_info]);
  467. }
  468. /**
  469. * @title 一级评论
  470. * @desc 一级评论
  471. * @author qc
  472. * @method POST
  473. * @url /api/Supplier/firstComment
  474. * @header name:Authorization require:1 desc:Token
  475. * @param name:goods_id type:int require:1 default:-- desc:问题的id
  476. * @param name:content type:string default:-- desc:内容
  477. * @return name:name type:string default:-- desc:会员名称
  478. * @return name:headimg type:string default:-- desc:会员头像
  479. * @return name:content type:string default:-- desc:内容
  480. * @return name:create_at type:string default:-- desc:时间
  481. */
  482. public function firstComment()
  483. {
  484. $goods_id = input('post.goods_id');
  485. $content = input('post.content');
  486. if (!$content) $this->error('请输入评论内容');
  487. $goods_info = SupplierGoods::where('id',$goods_id)->find()->toArray();
  488. if(!$goods_info['comment_switch']) $this->error('评论功能已关闭');
  489. $send_user = $goods_info['user_id'];
  490. $res = SupplierComment::create([
  491. 'user_id'=>$this->user_id,
  492. 'content'=>$content,
  493. 'goods_id'=>$goods_id,
  494. 'is_read' => $send_user == $this->user_id ? 1 : 0,
  495. 'source_read' => $send_user == $this->user_id ? 1 : 0,
  496. ]);
  497. $detail =SupplierComment::where('c.id',$res->id)
  498. ->alias('c')->field('c.id,c.content,c.user_id,c.create_at,u.name,u.headimg')
  499. ->leftJoin('store_member u','u.id = c.user_id')
  500. ->find()->toArray();
  501. $user_info = $this->userInfo('name');
  502. if($send_user && $this->user_id != $send_user) UserMessage:: sendUserMessage($send_user,'supplier',4,0,$this->user_id,$goods_id,$content);
  503. $this->success('评论成功',['detail'=>$detail]);
  504. }
  505. /**
  506. * @title 二级评论
  507. * @desc 二级评论
  508. * @author qc
  509. * @method POST
  510. * @url /api/Supplier/secondComment
  511. * @header name:Authorization require:1 desc:Token
  512. * @param name:id type:int default:1 desc:评论id
  513. * @param name:content type:string default:-- desc:内容
  514. * @return name:name type:string default:-- desc:会员名称
  515. * @return name:headimg type:string default:-- desc:会员头像
  516. * @return name:content type:string default:-- desc:内容
  517. * @return name:create_at type:string default:-- desc:时间
  518. */
  519. public function secondComment()
  520. {
  521. $content = input('post.content');
  522. if (!$content) $this->error('请输入评论内容');
  523. $comment = SupplierComment::where('id',input('post.id'))->find()->toArray();
  524. if($comment['user_id'] != $this->user_id)UserMessage:: sendUserMessage($comment['user_id'],'supplier',3,0,$this->user_id,$comment['id'],$content);
  525. $goods_info = SupplierGoods::where('id',$comment['goods_id'])->find()->toArray();
  526. if(!$goods_info['comment_switch']) $this->error('评论功能已关闭');
  527. //if($goods_info['user_id'] && $goods_info['user_id'] != $this->user_id) UserMessage:: sendUserMessage($goods_info['user_id'],'supplier',4,0,$this->user_id,$comment['goods_id'],$content);
  528. unset($comment['id']);
  529. unset($comment['create_at']);
  530. unset($comment['to_deleted']);
  531. unset($comment['is_top']);
  532. unset($comment['is_deleted']);
  533. $comment['pid'] = input('post.id');
  534. $comment['user_id'] = $this->user_id;
  535. $comment['content'] = $content;
  536. $comment['lev']++;
  537. $comment['is_read']= $this->user_id == $goods_info['user_id'] ? 1 :0 ;
  538. $comment['source_read'] = $this->user_id == $goods_info['user_id'] ? 1 :0 ;
  539. if(!$comment['source_id']) $comment['source_id'] = input('post.id');
  540. $res = SupplierComment::create($comment);
  541. $detail = SupplierComment::where('c.id',$res->id)->alias('c')->field('c.id,c.content,c.create_at,u.name,u.headimg')
  542. ->leftJoin('store_member u','u.id = c.user_id')->find()->toArray();
  543. $this->success('评论成功',['detail'=>$detail]);
  544. }
  545. /**
  546. * @title 获取评论列表
  547. * @desc 获取评论列表
  548. * @author qc
  549. * @method GET
  550. * @url /api/Supplier/getCommentList
  551. * @header name:Authorization require:1 desc:Token)
  552. * @param name:goods_id type:int default:-- desc:产品id
  553. * @param name:sort_type type:int default:1 desc:排序规则1最新2热点
  554. * @param name:page type:int default:1 desc:页数
  555. * @param name:page_num type:int default:20 desc:每页数
  556. * @return name:name type:string default:-- desc:会员名称
  557. * @return name:headimg type:string default:-- desc:会员头像
  558. * @return name:content type:string default:-- desc:内容
  559. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  560. * @return name:is_deleted type:int default:-- desc:是否删除(大于0未删除状态)
  561. * @return name:parent type:array default:-- desc:评论上一级(数据同上【一维数组】)
  562. * @return name:children type:array default:-- desc:二级评论(数据同上【二维数组】)
  563. * @return name:like_num type:int default:-- desc:点赞数量
  564. * @return name:is_like type:int default:-- desc:是否点赞(0否1是)
  565. * @return name:can_delete type:int default:-- desc:是否可以删除(0否1是)
  566. * @return name:total_num type:int default:-- desc:总评论数(仅一级)
  567. *
  568. */
  569. public function getCommentList()
  570. {
  571. $where = [];
  572. $where[] = ['c.goods_id','=',input('get.goods_id')];
  573. $where[] = ['c.is_deleted','=',0];
  574. $user_id = $this->user_id;
  575. $sort_type= input('sort_type',1);
  576. switch ($sort_type) {
  577. case 1:
  578. $order = ['c.is_top'=>'desc','c.id'=>'desc','c.like_times'=>'desc'];
  579. break;
  580. case 2:
  581. $order = ['c.is_top'=>'desc','c.like_times'=>'desc','c.id'=>'asc'];
  582. break;
  583. }
  584. $list = SupplierComment::where($where)
  585. ->alias('c')->field('c.*,u.name,u.headimg')
  586. ->leftJoin('store_member u','u.id = c.user_id')->order($order)
  587. ->limit($this->off_set,$this->page_num)
  588. ->select()->toArray();
  589. array_walk($list,function (&$val,$k)use($user_id){
  590. /* $children = SupplierComment::where(['c.pid'=>$val['id']])
  591. ->alias('c')->field('c.*,u.name,u.headimg')
  592. ->leftJoin('store_member u','u.id = c.user_id')
  593. ->order('c.is_top,c.id asc')
  594. ->select()->toArray();*/
  595. $val['like_num'] = PlatformLike::where('like_id',$val['id'])->where('type',11)->count();
  596. $val['like_num'] = numTransform($val['like_num']);
  597. // $val['children'] = $children;
  598. $val['is_like'] = PlatformLike::where(['like_id'=>$val['id'],'user_id'=>$user_id,'type'=>11])->count();
  599. $parent = SupplierComment::where(['c.id'=>$val['pid']])->alias('c')->field('c.*,u.name,u.headimg')->leftJoin('store_member u','u.id = c.user_id')->find();
  600. $val['parent'] = $parent ? $parent->toArray() : null;
  601. $val['parent_comment'] = $val['parent'] ;
  602. $val['can_delete'] = $val['user_id'] == $this->user_id ? 1 :0;
  603. });
  604. $total_num = SupplierComment::where($where)->alias('c')->count();
  605. $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
  606. }
  607. /**
  608. * @title 供应商搜索列表
  609. * @desc 供应商搜索列表
  610. * @author qc
  611. * @method GET
  612. * @url /api/Supplier/searchGoods
  613. * @header name:Authorization require:1 desc:Token
  614. * @param name:search_name type:int default:-- desc:搜索名称
  615. * @param name:page type:int default:0 desc:页数
  616. * @param name:page_num type:int default:20 desc:每页数
  617. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  618. *
  619. * @return name:name type:string default:-- desc:名称
  620. * @return name:supplier_name type:string default:-- desc:供应商名称
  621. * @return name:cover type:string default:-- desc:图片【多张逗号隔开】
  622. * @return name:cover_arr type:array default:-- desc:图片数组
  623. * @return name:label_name type:array default:-- desc:标签
  624. * @return name:content type:string default:-- desc:详情
  625. * @return name:read_num type:int default:-- desc:浏览量
  626. * @return name:article_id type:int default:-- desc:关联图文id【单个id||系列id】
  627. * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
  628. * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
  629. * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
  630. * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
  631. * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  632. * @return name:supplier_name type:string default:-- desc:供应商名称
  633. * @return name:supplier_logo type:string default:-- desc供应商logo
  634. * @return name:total_num type:array default:-- desc:总数
  635. *
  636. */
  637. public function searchGoods()
  638. {
  639. $search_name = input('get.search_name');
  640. $sort_type = input('get.sort_type',1);
  641. switch ($sort_type) {
  642. case 1:
  643. $order = ['g.sort'=>'desc','read_num'=>'desc','g.id'=>'asc'];
  644. break;
  645. case 2:
  646. $order = ['g.id'=>'asc','g.sort'=>'desc'];
  647. break;
  648. case 3:
  649. $order = ['g.id'=>'desc','g.sort'=>'desc'];
  650. break;
  651. }
  652. $sel_where = [];
  653. $sel_where[] = ['g.is_deleted','=',0];
  654. $sel_where[] = ['s.is_deleted','=',0];
  655. $sel_where[] = ['g.status','=',1];
  656. $sel_where[] = ['s.status','=',1];
  657. if($search_name && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$search_name,10);
  658. $list = SupplierGoods::where($sel_where)
  659. ->field('g.id,g.supplier_id,g.name,g.label,g.read_num,g.cover,s.title supplier_name,s.logo supplier_logo')
  660. ->when($search_name,function ($query)use($search_name){
  661. if($search_name) $query->where('g.name|g.label','like','%'.$search_name.'%');
  662. })->alias('g')
  663. ->leftJoin('Supplier s','g.supplier_id = s.id')
  664. ->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
  665. foreach ($list as &$v) {
  666. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
  667. $v['cover_arr'] =$v['cover'] ? explode('|',trim($v['cover'])):null;
  668. $v['read_num'] = numTransform($v['read_num']);
  669. }
  670. $total_num = SupplierGoods::where($sel_where)->alias('g')->leftJoin('Supplier s','g.supplier_id = s.id')->when($search_name,function ($query)use($search_name){
  671. if($search_name) $query->where('g.name|g.label','like','%'.$search_name.'%');
  672. })->count();
  673. $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
  674. }
  675. /**
  676. * @title 点赞||取消点赞
  677. * @desc 点赞||取消点赞
  678. * @author qc
  679. * @method POST
  680. * @url /api/Supplier/supplierTags
  681. * @header name:Authorization require:1 desc:Token
  682. * @param name:id type:int default:1 desc:记录id【产品id或评论id】
  683. * @param name:type type:int default:7 desc:7产品,11评论
  684. * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
  685. */
  686. public function supplierTags()
  687. {
  688. $type = input('post.type',7);
  689. $id = input('post.id');
  690. $ret_val = PlatformLike::userTags($this->user_id,$id,$type);
  691. $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
  692. }
  693. /**
  694. * @title 供应商产品收藏||取消收藏
  695. * @desc 用户收藏
  696. * @author qc
  697. * @method POST
  698. * @url /api/Supplier/supplierGoodsCollect
  699. * @header name:Authorization require:1 desc:Token
  700. * @param name:id type:int require:1 default:-- desc:供应商产品记录id
  701. * @param return:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
  702. */
  703. public function supplierGoodsCollect(){
  704. $coll_status = UserCollect::plateCollect($this->user_id,9,input('post.id',0));
  705. $coll_status ? $this->success('收藏成功',['status'=>1]) : $this->success('取消收藏成功',['status'=>0]);
  706. }
  707. /**
  708. * @title 转发(转发数量统计【供应商】)
  709. * @desc 转发成功后调用
  710. * @author qc
  711. * @method POST
  712. * @url /api/Supplier/supplierTransmit
  713. * @header name:Authorization require:1 desc:Token
  714. * @param name:id type:int default:-- desc:供应商记录id
  715. */
  716. public function supplierTransmit()
  717. {
  718. $id = input('post.id',0);
  719. \app\common\model\Supplier::where('id',$id)->setInc('transmit_num');
  720. $this->success('ok');
  721. }
  722. /**
  723. * @title 转发(转发数量统计【供应商产品】)
  724. * @desc 转发成功后调用
  725. * @author qc
  726. * @method POST
  727. * @url /api/Supplier/supplierGoodsTransmit
  728. * @header name:Authorization require:1 desc:Token
  729. * @param name:id type:int default:-- desc:供应商产品记录id
  730. */
  731. public function supplierGoodsTransmit()
  732. {
  733. $id = input('post.id',0);
  734. SupplierGoods::where('id',$id)->setInc('transmit_num');
  735. $this->success('ok');
  736. }
  737. /**
  738. * @title 我的浏览历史【供应商产品】
  739. * @desc 我的浏览历史
  740. * @author qc
  741. * @method GET
  742. * @url /api/Supplier/getSupplierGoodsTrack
  743. * @header name:Authorization require:1 desc:Token
  744. * @param name:name type:string default:-- desc:产品名称
  745. * @param name:page type:int default:-- desc:页数
  746. * @param name:page_num type:int default:-- desc:每页数
  747. * @return name:id type:string default:-- desc:浏览记录id
  748. * @return name:goods_id type:string default:-- desc:产品id
  749. * @return name:name type:string default:-- desc:产品名称
  750. * @return name:cover type:string default:-- desc:封面(多张|隔开)
  751. * @return name:cover_arr type:array default:-- desc:封面
  752. * @return name:label_name type:array default:-- desc:标签
  753. * @return name:supplier_logo type:string default:-- desc:供应商名称
  754. * @return name:supplier_name type:string default:-- desc:供应商名称
  755. * @return name:time type:string default:-- desc:时间
  756. * @return name:read_num type:string default:-- desc:浏览量
  757. */
  758. public function getSupplierGoodsTrack()
  759. {
  760. $sel_where = [];
  761. $sel_where[] = ['t.user_id','=',$this->user_id];
  762. $sel_where[] = ['t.type','=',10];
  763. $name = input('get.name');
  764. if($name) $sel_where[] = ['i.name|i.label','like','%'.$name.'%'];
  765. $list = UserTrack::where($sel_where)
  766. ->alias('t')
  767. ->field('t.id,t.update_int,t.first_id goods_id,i.read_num,i.name,i.cover,i.label,supplier_id,s.logo supplier_logo,s.title supplier_name')
  768. ->leftJoin('SupplierGoods i','t.first_id = i.id')
  769. ->leftJoin('Supplier s','s.id = i.supplier_id')
  770. ->order('update_int desc')
  771. ->limit($this->off_set,$this->page_num)
  772. ->select()->toArray();
  773. foreach ($list as &$v) {
  774. $v['time'] = date("Y-m-d",$v['update_int']);
  775. $v['cover_arr'] = $v['cover']? explode('|',$v['cover']) : null;
  776. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  777. $v['read_num'] = numTransform($v['read_num']);
  778. $v['is_normal'] = CheckPower::checkModulesPower($v['goods_id'],0,'supplier_goods');
  779. }
  780. $total_num =UserTrack::where($sel_where)->alias('t')->leftJoin('SupplierGoods i','t.first_id = i.id')->count();
  781. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  782. }
  783. /**
  784. * @title 我的点赞--产品
  785. * @desc 供应商产品点赞列表
  786. * @author qc
  787. * @method GET
  788. * @url /api/Supplier/getTagsSupplierGoods
  789. * @header name:Authorization require:1 desc:Token
  790. * @param name:name type:string default:-- desc:产品名称
  791. * @param name:page type:int default:-- desc:页数
  792. * @param name:page_num type:int default:-- desc:每页数
  793. * @return name:id type:string default:-- desc:浏览记录id
  794. * @return name:goods_id type:string default:-- desc:产品id
  795. * @return name:name type:string default:-- desc:名称
  796. * @return name:cover type:string default:-- desc:封面(多张|隔开)
  797. * @return name:cover_arr type:array default:-- desc:封面
  798. * @return name:label_name type:array default:-- desc:标签
  799. * @return name:supplier_name type:string default:-- desc:供应商名称
  800. * @return name:supplier_logo type:string default:-- desc:供应商logo
  801. * @return name:create_at type:string default:-- desc:时间
  802. * @return name:transmit_num type:string default:-- desc:转发量
  803. * @return name:comment_num type:string default:-- desc:评论量
  804. * @return name:praise_num type:int default:-- desc:点赞量
  805. * @return name:read_num type:int default:-- desc:阅读量
  806. * @return name:collect_num type:int default:-- desc:收藏量
  807. * @return name:is_collect type:int default:-- desc:是否收藏
  808. * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
  809. */
  810. public function getTagsSupplierGoods()
  811. {
  812. $sel_where = [];
  813. $name = input('get.name');
  814. if($name) $sel_where[] = ['i.name|i.label','like','%'.$name.'%'];
  815. $sel_where[] = ['t.user_id','=',$this->user_id];
  816. $sel_where[] = ['t.type','=',7];
  817. $list = PlatformLike::where($sel_where)->alias('t')
  818. ->field('t.id,t.create_at,t.like_id goods_id,i.transmit_num,i.name,i.cover,supplier_id,s.title supplier_name,s.logo supplier_logo,i.read_num')
  819. ->leftJoin('SupplierGoods i','t.like_id = i.id')
  820. ->leftJoin('Supplier s','s.id = i.supplier_id')
  821. ->order('id desc')
  822. ->limit($this->off_set,$this->page_num)
  823. ->select()->toArray();
  824. foreach ($list as &$v) {
  825. $v['cover_arr'] = explode('|',$v['cover']);
  826. $v['is_normal'] = CheckPower::checkModulesPower($v['goods_id'],0,'supplier_goods');
  827. $v['transmit_num'] = numTransform($v['transmit_num']);
  828. $v['read_num'] = numTransform($v['read_num']);
  829. $v['comment_num'] = SupplierComment::getCommentNum($v['goods_id']);
  830. $v['praise_num'] = PlatformLike::getPraiseNum($v['goods_id'],7);
  831. $v['collect_num'] =UserCollect::getCollectNum(9,$v['goods_id']);
  832. $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,9,$v['goods_id']);
  833. $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['goods_id'],11);
  834. }
  835. $total_num = PlatformLike::where($sel_where)->alias('t')->leftJoin('SupplierGoods i','t.like_id = i.id')->count();
  836. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  837. }
  838. /**
  839. * @title 我的点赞--评论
  840. * @desc 评论点赞列表
  841. * @author qc
  842. * @method GET
  843. * @url /api/Supplier/getTagsComment
  844. * @header name:Authorization require:1 desc:Token
  845. * @param name:page type:int default:0 desc:页数
  846. * @param name:page_num type:int default:20 desc:每页数
  847. * @return name:create_at type:string default:-- desc:时间
  848. * @return name:user_name type:string default:-- desc:会员名称
  849. * @return name:headimg type:string default:-- desc:会员头像
  850. * @return name:content type:string default:-- desc:评论内容
  851. * @return name:cover type:string default:-- desc:封面
  852. * @return name:ali_vid type:string default:-- desc:云点播id
  853. * @return name:read_num type:string default:-- desc:浏览量
  854. * @return name:supplier_name type:string default:-- desc:供应商名称
  855. * @return name:supplier_logo type:string default:-- desc:供应商logo
  856. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  857. */
  858. public function getTagsComment()
  859. {
  860. $list = PlatformLike::field('l.id,c.goods_id,c.content,c.id as like_id,g.read_num,g.name,g.cover,u.name user_name,u.headimg,s.title supplier_name,s.logo supplier_logo')
  861. ->alias('l')
  862. ->where(['l.user_id'=>$this->user_id,'l.type'=>11])
  863. ->where('c.user_id','<>',$this->user_id)
  864. ->leftJoin('SupplierComment c','l.like_id = c.id')
  865. ->leftJoin('SupplierGoods g','g.id = c.goods_id')
  866. ->leftJoin('Supplier s','s.id = g.supplier_id')
  867. ->leftJoin('store_member u','u.id = c.user_id')
  868. ->order('l.id desc')
  869. ->limit($this->off_set,$this->page_num)
  870. ->select()->toArray();
  871. array_walk($list,function (&$v){
  872. $v['read_num'] = numTransform($v['read_num']);
  873. $v['cover_arr'] = explode('|',$v['cover']);
  874. $v['is_normal'] = CheckPower::checkModulesPower($v['goods_id'],0,$this->request->controller());
  875. });
  876. $total_num = PlatformLike::alias('l')->where(['l.user_id'=>$this->user_id,'l.type'=>11]) ->where('c.user_id','<>',$this->user_id)
  877. ->leftJoin('SupplierComment c','l.like_id = c.id')->count();
  878. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  879. }
  880. /**
  881. * @title 我的收藏【供应商产品收藏列表】
  882. * @desc 供应商产品收藏列表
  883. * @author qc
  884. * @method GET
  885. * @url /api/Supplier/getCollectSupplierGoods
  886. * @header name:Authorization require:1 desc:Token
  887. * @param name:name type:string default:-- desc:产品名称
  888. * @param name:page type:int default:-- desc:页数
  889. * @param name:page_num type:int default:-- desc:每页数
  890. *
  891. * @return name:goods_id type:string default:-- desc:产品id
  892. * @return name:name type:string default:-- desc:名称
  893. * @return name:cover type:string default:-- desc:封面(多张|隔开)
  894. * @return name:cover_arr type:array default:-- desc:封面
  895. * @return name:label_name type:array default:-- desc:标签
  896. * @return name:supplier_name type:string default:-- desc:供应商名称
  897. * @return name:supplier_logo type:string default:-- desc:供应商logo
  898. * @return name:create_at type:string default:-- desc:时间
  899. * @return name:transmit_num type:string default:-- desc:转发量
  900. * @return name:comment_num type:string default:-- desc:评论量
  901. * @return name:praise_num type:int default:-- desc:点赞量
  902. * @return name:is_praise type:int default:-- desc:是否点赞
  903. * @return name:collect_num type:int default:-- desc:收藏量
  904. * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
  905. */
  906. public function getCollectSupplierGoods()
  907. {
  908. $sel_where = [];
  909. $name = input('get.name');
  910. if($name) $sel_where[] = ['i.name','like','%'.$name.'%'];
  911. $sel_where[] = ['t.user_id','=',$this->user_id];
  912. $sel_where[] = ['t.coll_type','=',9];
  913. $list = UserCollect::where($sel_where)->alias('t')
  914. ->field('t.id,t.create_at,t.coll_id goods_id,i.read_num,i.transmit_num,i.name,i.cover,i.label,i.supplier_id,s.logo supplier_logo ,s.title supplier_name')
  915. ->leftJoin('SupplierGoods i','t.coll_id = i.id')
  916. ->leftJoin('Supplier s','s.id = i.supplier_id')
  917. ->order('id desc')
  918. ->limit($this->off_set,$this->page_num)
  919. ->select()->toArray();
  920. foreach ($list as &$v) {
  921. $v['cover_arr'] = explode('|',$v['cover']);
  922. $v['label_name'] = explode(',',$v['label']);
  923. $v['read_num'] = numTransform($v['read_num']);
  924. $v['transmit_num'] = numTransform($v['transmit_num']);
  925. $v['comment_num'] = SupplierComment::getCommentNum($v['goods_id']);
  926. $v['is_praise'] = PlatformLike::checkTags($this->user_id,$v['goods_id'],7);
  927. $v['is_normal'] = CheckPower::checkModulesPower($v['goods_id'],0,'supplier_goods');
  928. $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['goods_id'],11);
  929. $v['collect_num'] = UserCollect::getCollectNum(9,$v['goods_id']);
  930. $v['praise_num'] = PlatformLike::getPraiseNum($v['goods_id'],7);
  931. }
  932. $total_num= UserCollect::where($sel_where)->alias('t') ->leftJoin('SupplierGoods i','t.coll_id = i.id')->count();
  933. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  934. }
  935. /**
  936. * @title 我的订阅--供应商
  937. * @desc 供应商
  938. * @author qc
  939. * @method GET
  940. * @url /api/Supplier/getFollowUpList
  941. * @header name:Authorization require:1 desc:Token
  942. * @param name:title type:string default:-- desc:搜索关键字
  943. * @param name:page type:int default:0 desc:页数
  944. * @param name:page_num type:int default:20 desc:每页数
  945. * @return name:create_at type:string default:-- desc:时间
  946. * @return name:title type:string default:-- desc:供应商标题
  947. * @return name:goods_num type:int default:-- desc:商品数量
  948. * @return name:supplier_id type:int default:-- desc:供应商id
  949. * @return name:supplier_name type:string default:-- desc:供应商名称
  950. * @return name:supplier_logo type:string default:-- desc:供应商logo
  951. * @return name:recently_title type:string default:-- desc:上次观看商品
  952. */
  953. public function getFollowUpList()
  954. {
  955. $sel_where = [];
  956. $sel_where[] = ['p.user_id','=',$this->user_id];
  957. $sel_where[] = ['p.type','=',5];
  958. $sel_where[] = ['p.switch_value','=',1];
  959. $field = 'p.id,p.switch_id as supplier_id,p.create_at,a.title,a.logo supplier_logo,a.title supplier_name';
  960. $list = PlatformSwitch::field($field)->alias('p')
  961. ->leftJoin('Supplier a','p.switch_id = a.id')
  962. ->where($sel_where)->limit($this->off_set,$this->page_num)->order('p.id desc')
  963. ->select()->toArray();
  964. array_walk($list,function (&$v){
  965. $v['goods_num'] = SupplierGoods::getGoodsNum($v['supplier_id']);
  966. $v['recently_title'] = UserTrack::getRecentlyGoodsName($this->user_id,$v['supplier_id']);
  967. });
  968. $total_num= PlatformSwitch::where($sel_where)->alias('p')->leftJoin('Supplier a','p.switch_id = a.id')->count();
  969. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  970. }
  971. /**
  972. * @title 我的订阅消息
  973. * @desc 我的订阅消息
  974. * @author qc
  975. * @method GET
  976. * @url /api/Supplier/getFollowUpMessage
  977. * @header name:Authorization require:1 desc:Token
  978. * @param name:title type:int default:-- desc:搜索内容
  979. * @param name:page type:int default:-- desc:页数
  980. * @param name:page_num type:int default:-- desc:每页数
  981. * @return name:id type:int default:-- desc:记录id
  982. * @return name:title type:string default:-- desc:标题
  983. * @return name:content type:string default:-- desc:内容
  984. * @return name:create_at type:string default:-- desc:时间
  985. * @return name:is_read type:int default:-- desc:是否已读【0否1是】
  986. * @return name:supplier_id type:int default:-- desc:供应商id
  987. * @return name:goods_id type:int default:-- desc:产品id
  988. */
  989. public function getFollowUpMessage()
  990. {
  991. $title = input('title');
  992. $list = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'supplier','m.type_id'=>5])
  993. ->alias('m')
  994. ->when($title,function ($query)use ($title){
  995. if($title) $query->where('m.content','like','%'.$title.'%');})
  996. ->field('m.id,v.create_at,m.title,m.is_read,m.children_id goods_id,m.content,m.relation_id supplier_id,m.module,v.title supplier_name')
  997. ->leftJoin('Supplier v','v.id= m.relation_id')
  998. ->limit($this->off_set,$this->page_num)
  999. ->order(['m.id'=>'desc'])
  1000. ->select()->toArray();
  1001. $total_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'supplier','m.type_id'=>5])->alias('m')->leftJoin('Supplier v','v.id= m.relation_id')->count();
  1002. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1003. }
  1004. /**
  1005. * @title 点赞我的--产品
  1006. * @desc 点赞我的--产品
  1007. * @author qc
  1008. * @method GET
  1009. * @url /api/Supplier/praiseGoodsList
  1010. * @header name:Authorization require:1 desc:Token
  1011. * @param name:page type:int default:-- desc:页数
  1012. * @param name:page_num type:int default:-- desc:每页数
  1013. * @return name:id type:int default:-- desc:记录id
  1014. * @return name:name type:string default:-- desc:产品
  1015. * @return name:create_at type:string default:-- desc:时间
  1016. * @return name:user_name type:string default:-- desc:会员名称
  1017. * @return name:headimg type:string default:-- desc:会员头像
  1018. * @return name:supplier_logo type:string default:-- desc:供应商logo
  1019. * @return name:supplier_name type:string default:-- desc:供应商名称
  1020. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1021. */
  1022. public function praiseGoodsList()
  1023. {
  1024. $sel_where = [];
  1025. $sel_where[] = ['p.type', '=', 7];
  1026. $sel_where[] = ['g.user_id', '=', $this->user_id];
  1027. $sel_where[] = ['p.to_deleted', '=', 0];
  1028. $list = PlatformLike::where($sel_where)
  1029. ->field('p.*,g.id goods_id,g.name,g.read_num,u.name user_name,u.headimg,s.logo supplier_logo ,s.title supplier_name,g.cover')->alias('p')
  1030. ->leftJoin('SupplierGoods g', 'g.id = p.like_id')
  1031. ->leftJoin('Supplier s', 's.id = g.supplier_id')
  1032. ->leftJoin('StoreMember u', 'u.id = p.user_id')
  1033. ->order('p.id desc')
  1034. ->limit($this->off_set,$this->page_num)
  1035. ->select()->toArray();
  1036. array_walk($list,function (&$v){
  1037. $v['read_num'] = numTransform($v['read_num']);
  1038. $v['cover_arr'] = $v['cover']? explode('|',trim($v['cover'],'|')):null;
  1039. $v['is_normal'] = CheckPower::checkModulesPower($v['goods_id'],0,'supplier_goods');
  1040. });
  1041. $total_num = PlatformLike::where($sel_where)->alias('p')
  1042. ->leftJoin('SupplierGoods g', 'g.id = p.like_id')
  1043. ->leftJoin('Supplier s', 's.id = g.supplier_id')
  1044. ->leftJoin('StoreMember u', 'u.id = p.user_id')
  1045. ->count();
  1046. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1047. }
  1048. /**
  1049. * @title 点赞我的--评论
  1050. * @desc 点赞我的
  1051. * @author qc
  1052. * @method GET
  1053. * @url /api/Supplier/praiseCommentList
  1054. * @header name:Authorization require:1 desc:Token
  1055. * @param name:page type:int default:-- desc:页数
  1056. * @param name:page_num type:int default:-- desc:每页数
  1057. * @return name:id type:int default:-- desc:记录id
  1058. * @return name:name type:string default:-- desc:产品
  1059. * @return name:create_at type:string default:-- desc:时间
  1060. * @return name:user_name type:string default:-- desc:会员名称
  1061. * @return name:headimg type:string default:-- desc:会员头像
  1062. * @return name:content type:string default:-- desc:评论内容
  1063. * @return name:supplier_logo type:string default:-- desc:供应商logo
  1064. * @return name:supplier_name type:string default:-- desc:供应商名称
  1065. * @return name:cover_arr type:array default:-- desc:图片
  1066. * @return name:goods_id type:int default:-- desc:产品id
  1067. * @return name:self_name type:string default:-- desc:自己昵称
  1068. * @return name:is_deleted type:int default:-- desc:评论是否删除(0未删除,1,2已删除)
  1069. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1070. */
  1071. public function praiseCommentList()
  1072. {
  1073. $sel_where = [];
  1074. $sel_where[] = ['p.type', '=', 11];
  1075. $sel_where[] = ['c.user_id', '=', $this->user_id];
  1076. $sel_where[] = ['p.to_deleted', '=', 0];
  1077. $list = PlatformLike::where($sel_where) ->alias('p')
  1078. ->field('p.*,c.content,c.is_deleted,g.read_num,c.goods_id,u.name user_name,u.headimg,s.logo supplier_logo ,s.title supplier_name,g.cover,g.name')
  1079. ->leftJoin('SupplierComment c', 'c.id = p.like_id')
  1080. ->leftJoin('SupplierGoods g', 'g.id = c.goods_id')
  1081. ->leftJoin('Supplier s', 's.id = g.supplier_id')
  1082. ->leftJoin('StoreMember u', 'u.id = p.user_id')
  1083. ->order('p.id desc')
  1084. ->limit($this->off_set,$this->page_num)
  1085. ->select()->toArray();
  1086. array_walk($list,function (&$v){
  1087. $v['self_name'] = $this->user_info['name'];
  1088. $v['read_num'] = numTransform($v['read_num']);
  1089. $v['cover_arr'] = $v['cover']? explode('|',trim($v['cover'],'|')):null;
  1090. $v['is_normal'] = CheckPower::checkModulesPower($v['goods_id'],0,'supplier_goods');
  1091. });
  1092. $total_num = PlatformLike::where($sel_where) ->alias('p')->leftJoin('SupplierComment c', 'c.id = p.like_id')
  1093. ->leftJoin('SupplierGoods g', 'g.id = c.goods_id')
  1094. ->leftJoin('Supplier s', 's.id = g.supplier_id')
  1095. ->leftJoin('StoreMember u', 'u.id = p.user_id')->count();
  1096. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  1097. }
  1098. /**
  1099. * @title 我的发布
  1100. * @desc 我的发布
  1101. * @author qc
  1102. * @method GET
  1103. * @url /api/Supplier/getMyGoodsList
  1104. * @header name:Authorization require:1 desc:Token
  1105. * @param name:page type:int default:-- desc:页数
  1106. * @param name:page_num type:int default:-- desc:每页数
  1107. * @param name:title type:string default:-- desc:关键词
  1108. * @return name:id type:int default:-- desc:产品id
  1109. * @return name:name type:string default:-- desc:产品
  1110. * @return name:create_at type:string default:-- desc:时间
  1111. * @return name:supplier_logo type:string default:-- desc:供应商logo
  1112. * @return name:supplier_name type:string default:-- desc:供应商名称
  1113. * @return name:cover_arr type:array default:-- desc:图片
  1114. */
  1115. public function getMyGoodsList()
  1116. {
  1117. $where = [];
  1118. $where[] = ['user_id','=',$this->user_id];
  1119. $where[] = ['is_deleted','=',0];
  1120. $where[] = ['status','=',1];
  1121. $title = input('get.title');
  1122. if ($title) $where[] = ['name', 'like', '%' . $title . '%'];
  1123. $list = SupplierGoods::where($where)
  1124. ->field('id,name,create_at,label,cover,read_num')
  1125. ->order('id desc')
  1126. ->limit($this->off_set,$this->page_num)
  1127. ->select()->toArray();
  1128. array_walk($list,function (&$v){
  1129. $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')):null;
  1130. $v['cover_arr'] = $v['cover']? explode('|',trim($v['cover'],'|')):null;
  1131. });
  1132. $total_num = SupplierGoods::where($where)->count();
  1133. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  1134. }
  1135. /**
  1136. * @title 评论我的
  1137. * @desc 评论我的
  1138. * @author qc
  1139. * @method GET
  1140. * @url /api/Supplier/commentOnMyGoods
  1141. * @header name:Authorization require:1 desc:Token
  1142. * @param name:title type:string default:-- desc:关键字
  1143. * @param name:page type:int default:-- desc:页数
  1144. * @param name:page_num type:int default:-- desc:每页数量
  1145. * @return name:create_at type:string default:-- desc:时间
  1146. * @return name:content type:string default:0 desc:评论内容
  1147. * @return name:user_name type:string default:-- desc:评论用户
  1148. * @return name:headimg type:string default:-- desc:评论用户头像
  1149. * @return name:is_deleted type:int default:-- desc:是否删除(0否1是)
  1150. * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
  1151. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1152. * @return name:cover_arr type:array default:-- desc:图片
  1153. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1154. */
  1155. public function commentOnMyGoods()
  1156. {
  1157. $where = [];
  1158. $where[] = ['g.user_id', '=', $this->user_id];
  1159. $where[] = ['c.is_deleted', '=', 0];
  1160. $where[] = ['c.user_id', '<>', $this->user_id];
  1161. $where[] = ['c.to_deleted', '=', 0];
  1162. $where[] = ['c.pid','=',0];
  1163. if ($title = input('title')) $where[] = ['c.content', 'like', '%' . $title . '%'];
  1164. $list = SupplierComment::field('c.*,m.name user_name,m.headimg,g.name,s.logo supplier_logo ,s.title supplier_name,g.cover,g.read_num')
  1165. ->alias('c')->where($where)
  1166. ->leftJoin('store_member m', 'm.id = c.user_id')
  1167. ->leftJoin('SupplierGoods g', 'g.id = c.goods_id')
  1168. ->leftJoin('Supplier s', 's.id = g.supplier_id')
  1169. ->order('c.is_top desc,c.id desc')
  1170. ->limit($this->off_set, $this->page_num)
  1171. ->select()->toArray();
  1172. array_walk($list, function (&$v) {
  1173. // $v['is_read'] = $v['source_read'];
  1174. $v['is_normal'] = CheckPower::checkModulesPower($v['goods_id'], 0, 'supplier_goods');
  1175. $v['cover_arr'] = $v['cover']? explode('|',trim($v['cover'],'|')):null;
  1176. $v['read_num'] = numTransform($v['read_num']);
  1177. });
  1178. $total_num = SupplierComment::where($where)->alias('c')
  1179. ->leftJoin('store_member m', 'm.id = c.user_id')
  1180. ->leftJoin('SupplierGoods g', 'g.id = c.goods_id')
  1181. ->leftJoin('Supplier s', 's.id = g.supplier_id')->count();
  1182. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  1183. }
  1184. /**
  1185. * @title 回复我的
  1186. * @desc 回复我的
  1187. * @author qc
  1188. * @method GET
  1189. * @url /api/Supplier/getReplayComment
  1190. * @header name:Authorization require:1 desc:Token
  1191. * @param name:title type:string default:-- desc:标题
  1192. * @param name:page type:int default:0 desc:页数
  1193. * @param name:page_num type:int default:20 desc:每页数
  1194. * @return name:id type:int default:-- desc:记录id
  1195. * @return name:title type:string default:-- desc:问题标题
  1196. * @return name:create_at type:string default:-- desc:时间
  1197. * @return name:is_deleted type:int default:-- desc:回复内容是被删除【0否】
  1198. * @return name:user_name type:string default:-- desc:用户名【其他会员】
  1199. * @return name:headimg type:string default:-- desc:用户头像【其他会员】
  1200. * @return name:content type:string default:-- desc:回复内容
  1201. * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
  1202. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1203. * @return name:self_name type:string default:-- desc:自己昵称
  1204. * @return name:parent_comment type:array default:-- desc:你的评论内容【阴影部分】
  1205. * @return name:parent_comment.content type:string default:-- desc:内容
  1206. * @return name:parent_comment.is_normal type:int default:-- desc:能否跳转(0已删除或是已禁用1可以正常跳转详情)
  1207. * @return name:parent_comment.is_deleted type:int default:-- desc:被评论的内容是否删除
  1208. * @return name:parent_comment.read_num type:string default:-- desc:阅读量
  1209. * @return name:parent_comment.goods_name type:string default:-- desc:产品名称
  1210. * @return name:parent_comment.name type:string default:-- desc:你的会员名称
  1211. * @return name:parent_comment.headimg type:string default:-- desc:你的头像
  1212. * @return name:parent_comment.show_title type:string default:-- desc:展示的问题标题或答案内容
  1213. * @return name:parent_comment.reply_id type:int default:-- desc:答案id【值为0是问题类型,大于0是答案类型】
  1214. *
  1215. */
  1216. public function getReplayComment()
  1217. {
  1218. $all_comment = SupplierComment::where(['user_id'=> $this->user_id, 'is_deleted' => 0])->column('id');
  1219. if (empty($all_comment)) $this->success('ok', ['list' => null]);
  1220. $sel_where = [];
  1221. $title = input('get.title');
  1222. if ($title) $sel_where[] = ['t.content', 'like', '%' . $title . '%'];
  1223. $sel_where[] = ['t.to_deleted', '=', 0];
  1224. $sel_where[] = ['t.user_id','<>',$this->user_id];
  1225. $sel_where[] = ['t.pid', 'in', implode(',', $all_comment)];
  1226. $list = SupplierComment::where($sel_where)
  1227. ->alias('t')
  1228. ->field('t.id,t.is_top,t.create_at,t.is_read,t.content,t.is_deleted,t.pid,goods_id,u.name user_name,u.headimg')
  1229. ->leftJoin('store_member u', 't.user_id = u.id')
  1230. ->order('t.is_top desc,t.id desc')
  1231. ->limit($this->off_set, $this->page_num)
  1232. ->select()->toArray();
  1233. array_walk($list,function (&$v){
  1234. $v['self_name'] = $this->user_info['name'];
  1235. $parent_comment = SupplierComment::where([['t.id', '=', $v['pid']]])
  1236. ->alias('t')
  1237. ->field('t.id,t.content,t.is_deleted,i.read_num,goods_id,i.name goods_name,s.logo supplier_logo ,s.title supplier_name,i.cover,u.name,u.headimg')
  1238. ->leftJoin('store_member u', 't.user_id = u.id')
  1239. ->leftJoin('SupplierGoods i', 't.goods_id = i.id')
  1240. ->leftJoin('Supplier s', 'i.supplier_id = s.id')
  1241. ->find()->toArray();
  1242. $parent_comment['cover_arr'] = $parent_comment['cover']? explode('|',trim($parent_comment['cover'],'|')):null;
  1243. $parent_comment['read_num'] = numTransform($parent_comment['read_num']);
  1244. $parent_comment['is_normal'] =CheckPower::checkModulesPower($parent_comment['goods_id'], 0, 'supplier');
  1245. $v['parent_comment'] = $parent_comment;
  1246. });
  1247. $total_num = SupplierComment::where($sel_where)->alias('t')
  1248. ->leftJoin('store_member u', 't.user_id = u.id')
  1249. ->count();
  1250. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  1251. }
  1252. /**
  1253. * @title 获取角标数量
  1254. * @desc 获取角标数量
  1255. * @author qc
  1256. * @method GET
  1257. * @url /api/Supplier/getMarkNum
  1258. * @header name:Authorization require:1 desc:Token
  1259. * @return name:comment_num type:int default:-- desc:评论我的【总数量】
  1260. * @return name:reply_num type:int default:-- desc:回复我的【总数量】
  1261. * @return name:follow_num type:int default:-- desc:订阅
  1262. * @return name:praise_num type:int default:-- desc:点赞我的【包含产品点赞和评论点赞】
  1263. * @return name:total_num type:int default:-- desc:总数【comment_num+reply_num+follow_num】
  1264. */
  1265. public function getMarkNum()
  1266. {
  1267. // 评论我的
  1268. $comment_num = SupplierComment::where([['g.user_id', '=', $this->user_id],['c.is_deleted', '=', 0],['c.to_deleted', '=', 0],['c.is_read','=',0],['c.pid','=',0]])
  1269. ->alias('c') ->leftJoin('SupplierGoods g', 'g.id = c.goods_id')->count();
  1270. //回复我的
  1271. $all_comment = SupplierComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1272. $reply_num = $all_comment ? SupplierComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.is_read','=',0],['t.pid','in',implode(',',$all_comment)]])->alias('t')->count() :0;
  1273. //订阅
  1274. $follow_num = UserMessage::getUnreadNum($this->user_id,'supplier',5);
  1275. $total_num = $comment_num + $reply_num + $follow_num;
  1276. $praise_supplier = PlatformLike::where([['p.type', '=', 7],['f.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0]])->alias('p') ->leftJoin('SupplierGoods f', 'f.id = p.like_id')->count();
  1277. $praise_comment = PlatformLike::where([['p.type', '=', 11],['c.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0]])->alias('p')->leftJoin('SupplierComment c', 'c.id = p.like_id')->count();
  1278. $praise_num = $praise_supplier + $praise_comment;
  1279. $this->success('ok', compact([ 'comment_num','reply_num','follow_num','praise_num','total_num']));
  1280. }
  1281. /**
  1282. * @title 我的回复【我的回复--我回复过的评论】
  1283. * @desc 我的回复
  1284. * @author qc
  1285. * @method GET
  1286. * @url /api/Supplier/getReplyComment
  1287. * @header name:Authorization require:1 desc:Token
  1288. * @param name:title type:string default:-- desc:标题
  1289. * @param name:page type:int default:0 desc:页数
  1290. * @param name:page_num type:int default:20 desc:每页数
  1291. * @return name:create_at type:string default:-- desc:时间
  1292. * @return name:content type:string default:-- desc:回复内容
  1293. * @return name:user_name type:string default:-- desc:用户名【用户自己的】
  1294. * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
  1295. *
  1296. * @return name:parent_comment type:array default:-- desc:上级评论内容【阴影部分--你回复的那个】
  1297. * @return name:parent_comment.content type:string default:-- desc:内容
  1298. * @return name:parent_comment.goods_name type:string default:-- desc:产品名称
  1299. * @return name:parent_comment.name type:string default:-- desc:会员名称【别人的】
  1300. * @return name:parent_comment.headimg type:string default:-- desc:会员头像【别人的】
  1301. * @return name:parent_comment.title type:string default:-- desc:标题
  1302. * @return name:parent_comment.goods_id type:int default:-- desc:商品id
  1303. * @return name:parent_comment.supplier_logo type:string default:-- desc:供应商logo
  1304. * @return name:parent_comment.supplier_name type:string default:-- desc:供应商名称
  1305. * @return name:parent_comment.is_deleted type:int default:-- desc:评论删除状态(0未删除)
  1306. * @return name:parent_comment.is_normal type:int default:-- desc:产品状态
  1307. * @return name:parent_comment.cover_arr type:array default:-- desc:产品封面
  1308. * @return name:parent_comment.read_num type:string default:-- desc:浏览量
  1309. */
  1310. public function getReplyComment()
  1311. {
  1312. $sel_where = [];
  1313. $title = input('get.title');
  1314. if($title) $sel_where[] = ['t.content','like','%'.$title.'%'];
  1315. $sel_where[] = ['t.user_id', '=', $this->user_id];
  1316. // $sel_where[] = ['c.user_id', '<>', $this->user_id];
  1317. $sel_where[] = ['t.to_deleted', '=', 0];
  1318. $sel_where[] = ['t.pid', '>', 0];
  1319. $list = SupplierComment::where($sel_where)->alias('t')
  1320. ->field('t.id,t.is_top,t.create_at,t.content,t.pid,t.goods_id,t.is_deleted')
  1321. ->leftJoin('SupplierComment c', 'c.id = t.pid')
  1322. ->order('t.id desc')
  1323. ->limit($this->off_set, $this->page_num)
  1324. ->select()->toArray();
  1325. array_walk($list,function (&$v){
  1326. $v['user_name'] = $this->user_info['name'];
  1327. $v['headimg'] = $this->user_info['headimg'];
  1328. $parent_comment = SupplierComment::where([['t.id', '=', $v['pid']]])
  1329. ->field('t.id,t.content,t.pid,t.goods_id,u.name,u.headimg,i.name goods_name,i.read_num,i.cover,i.is_deleted,s.logo supplier_logo ,s.title supplier_name')
  1330. ->alias('t')->leftJoin('SupplierGoods i', 't.goods_id = i.id')
  1331. ->leftJoin('Supplier s', 'i.supplier_id = s.id')
  1332. ->leftJoin('store_member u', 't.user_id = u.id')
  1333. ->find()->toArray();
  1334. $parent_comment['is_normal'] = CheckPower::checkModulesPower($v['goods_id'],0,$this->request->controller());
  1335. $parent_comment['read_num'] = numTransform($parent_comment['read_num']);
  1336. $parent_comment['cover_arr'] = $parent_comment['cover']? explode('|',trim($parent_comment['cover'],'|')):null;
  1337. $v['parent_comment'] = $parent_comment;
  1338. });
  1339. $total_num = SupplierComment::where($sel_where)->alias('t') ->leftJoin('SupplierComment c', 'c.id = t.pid')->count();
  1340. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  1341. }
  1342. /**
  1343. * @title 我的评论
  1344. * @desc 我的评论
  1345. * @author qc
  1346. * @method GET
  1347. * @url /api/Supplier/myDiscuss
  1348. * @header name:Authorization require:1 desc:Token
  1349. * @param name:title type:string default:-- desc:关键字
  1350. * @param name:page type:int default:-- desc:页数
  1351. * @param name:page_num type:int default:-- desc:每页数量
  1352. * @return name:create_at type:string default:-- desc:时间
  1353. * @return name:goods_name type:string default:-- desc:产品名称
  1354. * @return name:content type:string default:0 desc:评论内容
  1355. * @return name:name type:string default:-- desc:用户名
  1356. * @return name:headimg type:string default:-- desc:头像
  1357. * @return name:supplier_logo type:string default:-- desc:供应商logo
  1358. * @return name:supplier_name type:string default:-- desc:供应商名称
  1359. * @return name:read_num type:string default:-- desc:阅读量
  1360. * @return name:cover_arr type:array default:-- desc:封面
  1361. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1362. */
  1363. public function myDiscuss()
  1364. {
  1365. $where = [];
  1366. $where[] = ['c.is_deleted', '=', 0];
  1367. if ($title = input('title')) $where[] = ['c.content', 'like', '%' . $title . '%'];
  1368. $where[] = ['c.user_id', '=', $this->user_id];
  1369. $where[] = ['c.pid', '=', 0];
  1370. $where[] = ['c.is_deleted', '=', 0];
  1371. $list = SupplierComment::field('c.*,m.name,m.headimg,g.name goods_name,g.read_num,s.logo supplier_logo ,s.title supplier_name,g.cover')->alias('c')
  1372. ->where($where)
  1373. ->leftJoin('store_member m', 'm.id = c.user_id')
  1374. ->leftJoin('SupplierGoods g', 'g.id = c.goods_id')
  1375. ->leftJoin('Supplier s', 's.id = g.supplier_id')
  1376. ->order('c.is_top desc,c.id desc')
  1377. ->limit($this->off_set, $this->page_num)
  1378. ->select()->toArray();
  1379. array_walk($list, function (&$v) {
  1380. $v['read_num'] = numTransform($v['read_num']);
  1381. $v['is_normal'] = CheckPower::checkModulesPower($v['goods_id'],0,'supplier_goods');
  1382. $v['cover_arr'] = $v['cover']? explode('|',trim($v['cover'],'|')):null;
  1383. });
  1384. $total_num = SupplierComment::where($where)
  1385. ->alias('c')
  1386. ->leftJoin('store_member m', 'm.id = c.user_id')
  1387. ->leftJoin('SupplierGoods g', 'g.id = c.goods_id')
  1388. ->leftJoin('Supplier s', 's.id = g.supplier_id')->count();
  1389. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  1390. }
  1391. /**
  1392. * @title 批量删除||批量取消
  1393. * @desc 删除||取消
  1394. * @author qc
  1395. * @method POST
  1396. * @url /api/Supplier/batchesDel
  1397. * @header name:Authorization require:1 desc:Token
  1398. * @param name:id type:string default:1 desc:记录id【多个用逗号隔开=>'1,2'】
  1399. * @param name:type type:string default:1 desc:消息类型【1我的评论,2评论我的,3我的回复,4订阅记录,5追番消息,6我的点赞-产品,7我的点赞-评论,8回复我的,9点赞我的--产品,10点赞我的--评论,11我的收藏】
  1400. */
  1401. public function batchesDel()
  1402. {
  1403. $type = input('post.type',1);
  1404. $del_where = [];
  1405. $del_where[] = ['id','in',input('post.id')];
  1406. if(in_array($type,[1,3,4,5,6,7])) $del_where[] = ['user_id','=',$this->user_id];
  1407. if(in_array($type,[1,3])) SupplierComment::where($del_where)->update(['is_deleted'=>1]);
  1408. if(in_array($type,[2])) SupplierComment::where($del_where)->update(['source_deleted'=>1,'source_read'=>1,'is_read'=>1]);
  1409. if(in_array($type,[4])) PlatformSwitch::where($del_where)->delete();
  1410. if(in_array($type,[5])) UserMessage::where($del_where)->update(['is_deleted'=>1]);
  1411. if(in_array($type,[6,7])) PlatformLike::where($del_where)->delete();
  1412. if(in_array($type,[8])) SupplierComment::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
  1413. if(in_array($type,[9,10])) PlatformLike::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
  1414. if(in_array($type,[11])) UserCollect::where($del_where)->delete();
  1415. $this->success('操作成功');
  1416. }
  1417. /**
  1418. * @title 消息已读&&未读变更
  1419. * @desc 支持批量选择
  1420. * @author qc
  1421. * @method POST
  1422. * @url /api/Supplier/unreadChange
  1423. * eadChange
  1424. * @header name:Authorization require:1 desc:Token
  1425. * @param name:id type:string default:-- desc:记录id(多个逗号隔开,不传修改全部])
  1426. * @param name:type type:string default:1 desc:消息类型【1评论我的,2回复我的,3订阅消息,4点赞我的】
  1427. * @param name:is_read type:int default:1 desc:变更类型【0消息变更为未读,1变更为已读】
  1428. */
  1429. public function unreadChange()
  1430. {
  1431. $type = input('post.type',1);
  1432. $id = input('post.id');
  1433. $is_read = input('post.is_read');
  1434. $where = [];
  1435. switch ($type) {
  1436. case 1:
  1437. SupplierComment::where([['i.user_id','=',$this->user_id]])
  1438. ->when($id ,function ($query)use ($id){
  1439. if($id) return $query->where('t.id','in',$id);
  1440. })->leftJoin('SupplierGoods i','t.goods_id = i.id')
  1441. ->alias('t') ->update(['source_read'=>$is_read,'is_read'=>$is_read]);
  1442. break;
  1443. case 2:
  1444. $all_comment = SupplierComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1445. SupplierComment::where([['t.pid','in',implode(',',$all_comment)]])
  1446. ->when($id ,function ($query)use ($id){
  1447. if($id) return $query->where('t.id','in',$id);
  1448. })->alias('t')->update(['is_read'=>$is_read]);
  1449. break;
  1450. case 3:
  1451. $where[] = ['user_id','=',$this->user_id];
  1452. if($id) $where[] = ['id','in',$id];
  1453. UserMessage::where($where)->update(['is_read'=>$is_read]);
  1454. break;
  1455. case 4:
  1456. PlatformLike::where([['p.type', '=', 7],['f.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0]])->alias('p') ->leftJoin('SupplierGoods f', 'f.id = p.like_id')->update(['p.is_read'=>1]);
  1457. PlatformLike::where([['p.type', '=', 11],['c.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0]])->alias('p')->leftJoin('SupplierComment c', 'c.id = p.like_id')->update(['p.is_read'=>1]);
  1458. break;
  1459. }
  1460. $this->success('消息变更成功');
  1461. }
  1462. }