企微短剧业务系统

PortraitController.php 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Service\PortraitService;
  4. use App\Service\TagService;
  5. use Illuminate\Http\Request;
  6. use App\Http\Controllers\Controller;
  7. class PortraitController extends Controller
  8. {
  9. /**
  10. * 画像配置列表
  11. * @param Request $request
  12. * @return array
  13. */
  14. public function confList(Request $request)
  15. {
  16. $validator = \Validator::make($request->all(),[
  17. 'corpid' => 'required|string'
  18. ]);
  19. if ($validator->fails()) {
  20. return self::returnValue($validator->getMessageBag(), 1102);
  21. }
  22. $corpid = $request->input('corpid');
  23. $res = PortraitService::confList($corpid);
  24. return self::returnValue($res);
  25. }
  26. /**
  27. * 画像配置操作
  28. * @param Request $request
  29. * @return array
  30. */
  31. public function confOperate(Request $request)
  32. {
  33. $validator = \Validator::make($request->all(),[
  34. 'corpid' => 'required|string',
  35. 'conf_json' => 'required|string'
  36. ]);
  37. if ($validator->fails()) {
  38. return self::returnValue($validator->getMessageBag(), 1102);
  39. }
  40. $corpid = $request->input('corpid');
  41. $confJson = $request->input('conf_json');
  42. list($res, $code) = PortraitService::confOperate($corpid, $confJson);
  43. return self::returnValue($res, $code);
  44. }
  45. /**
  46. * 画像配置添加属性
  47. * @param Request $request
  48. * @return array
  49. */
  50. public function confAdd(Request $request)
  51. {
  52. $validator = \Validator::make($request->all(),[
  53. 'corpid' => 'required|string',
  54. 'name' => 'required|string'
  55. ]);
  56. if ($validator->fails()) {
  57. return self::returnValue($validator->getMessageBag(), 1102);
  58. }
  59. $corpid = $request->input('corpid');
  60. $name = $request->input('name');
  61. list($res, $code) = PortraitService::confAdd($corpid, $name);
  62. return self::returnValue($res, $code);
  63. }
  64. /**
  65. * 画像属性编辑
  66. * @param Request $request
  67. * @return array
  68. */
  69. public function confEdit(Request $request)
  70. {
  71. $validator = \Validator::make($request->all(),[
  72. 'corpid' => 'required|string',
  73. 'fid' => 'required|string',
  74. 'name' => 'required|string'
  75. ]);
  76. if ($validator->fails()) {
  77. return self::returnValue($validator->getMessageBag(), 1102);
  78. }
  79. $corpid = $request->input('corpid');
  80. $fid = $request->input('fid');
  81. $name = $request->input('name');
  82. list($res, $code) = PortraitService::confEdit($corpid, $fid, $name);
  83. return self::returnValue($res, $code);
  84. }
  85. /**
  86. * 客户画像编辑
  87. * @param Request $request
  88. * @return array
  89. */
  90. public function edit(Request $request)
  91. {
  92. $validator = \Validator::make($request->all(),[
  93. 'corpid' => 'required|string',
  94. 'user_id' => 'required|string',
  95. 'external_userid' => 'required|string',
  96. 'attrs_json' => 'required|string'
  97. ]);
  98. if ($validator->fails()) {
  99. return self::returnValue($validator->getMessageBag(), 1102);
  100. }
  101. $corpid = $request->input('corpid');
  102. $userId = $request->input('user_id');
  103. $externalUserid = $request->input('external_userid');
  104. $attrsJson = $request->input('attrs_json');
  105. list($res, $code) = PortraitService::edit($corpid, $userId, $externalUserid, $attrsJson);
  106. return self::returnValue($res, $code);
  107. }
  108. public function h5CustomerDetail(Request $request)
  109. {
  110. $validator = \Validator::make($request->all(),[
  111. 'corpid' => 'required',
  112. 'external_userid' => 'required|string',
  113. 'user_id' => 'required|string'
  114. ]);
  115. if ($validator->fails()) {
  116. return self::returnValue($validator->getMessageBag(), 1102);
  117. }
  118. $corpid = $request->input('corpid');
  119. $external_userid = $request->input('external_userid');
  120. $userId = $request->input('user_id');
  121. list($data, $code) = PortraitService::h5CustomerDetail($corpid, $external_userid, $userId);
  122. return self::returnValue($data, $code);
  123. }
  124. public function h5CustomerDynamicList(Request $request)
  125. {
  126. $validator = \Validator::make($request->all(),[
  127. 'corpid' => 'required',
  128. 'external_userid' => 'required|string',
  129. 'user_id' => 'required|string'
  130. ]);
  131. if ($validator->fails()) {
  132. return self::returnValue($validator->getMessageBag(), 1102);
  133. }
  134. $corpid = $request->input('corpid');
  135. $external_userid = $request->input('external_userid');
  136. $userId = $request->input('user_id');
  137. $data = PortraitService::h5CustomerDynamicList($corpid, $external_userid);
  138. return self::returnValue($data);
  139. }
  140. public function h5CustomerOrderList(Request $request)
  141. {
  142. $validator = \Validator::make($request->all(),[
  143. 'corpid' => 'required',
  144. 'external_userid' => 'required|string',
  145. 'user_id' => 'required|string',
  146. 'page' => 'required|int',
  147. 'pagesize' => 'nullable|int',
  148. ]);
  149. if ($validator->fails()) {
  150. return self::returnValue($validator->getMessageBag(), 1102);
  151. }
  152. $corpid = $request->input('corpid');
  153. $external_userid = $request->input('external_userid');
  154. $userId = $request->input('user_id');
  155. $page = $request->input('page', 1);
  156. $pagesize = $request->input('page_size', 20);
  157. list($data, $total) = PortraitService::h5CustomerOrderList($corpid, $external_userid, $page, $pagesize);
  158. return self::returnPageValue($data, $total, $pagesize, $page);
  159. }
  160. // 客户详情标签编辑
  161. public function h5CustomerTagUpdate(Request $request)
  162. {
  163. $validator = \Validator::make($request->all(),[
  164. 'corpid' => 'required',
  165. 'external_userid' => 'required|string',
  166. 'user_id' => 'required|string',
  167. 'selected_tag_id_list' => 'required|array',
  168. ]);
  169. if ($validator->fails()) {
  170. return self::returnValue($validator->getMessageBag(), 1102);
  171. }
  172. $corpid = $request->input('corpid');
  173. $externalUserId = $request->input('external_userid');
  174. $userId = $request->input('user_id');
  175. $selectedTagIdList = $request->input('selected_tag_id_list');
  176. list($res, $code) = PortraitService::h5CustomerDetailTagUpdate($corpid, $externalUserId, $userId, $selectedTagIdList);
  177. return self::returnValue($res, $code);
  178. }
  179. //标签列表(按标签组分组返回)
  180. public function h5TagList(Request $request)
  181. {
  182. $validator = \Validator::make($request->all(),[
  183. 'corpid' => 'required',
  184. ]);
  185. if ($validator->fails()) {
  186. return self::returnValue($validator->getMessageBag(), 1102);
  187. }
  188. $corpid = $request->input('corpid');
  189. $keyword = $request->input('keyword');
  190. $data = TagService::tagList($corpid, $keyword);
  191. return self::returnValue($data);
  192. }
  193. }