Index.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <?php
  2. namespace app\youzan\controller;
  3. use app\admin\controller\Base;
  4. use app\youzan\logic\Cat;
  5. use app\youzan\logic\Order;
  6. use app\youzan\logic\Tag;
  7. use app\youzan\logic\Goodup;
  8. use think\facade\Validate;
  9. //有赞对接类
  10. class Index extends Base
  11. {
  12. //获取有赞的类目列表
  13. public function getYzCatList()
  14. {
  15. $parent_cid = $this->request->post('parent_cid/d', 0, 'trim');
  16. $rs = Cat::getYzCatList($parent_cid);
  17. return app_show(0, '请求成功', $rs);
  18. }
  19. //获取有赞的标签列表
  20. public function getYzTagList()
  21. {
  22. $rs = Tag::getYzTagList();
  23. return app_show(0, '请求成功', $rs);
  24. }
  25. //审核并将商品推送到有赞平台
  26. public function checkExamstatus()
  27. {
  28. $param = $this->request->only(['platform_youzan_id', 'exam_status', 'reject_reason', 'yz_cat_id'=>0, 'is_support_barter', 'good_ladder_id', 'final_price', 'start_sale_num', 'tags' => [], 'item_type' => 0, 'auto_listing_time' => '0', 'origin' => 0,'relaComNo','distribution'=>[1]], 'post', 'trim');
  29. $val = Validate::rule([
  30. 'platform_youzan_id|商品上线记录ID' => 'require|number|gt:0',
  31. 'exam_status|审核状态' => 'require|number|in:1,2',
  32. 'reject_reason|驳回原因' => 'requireIf:exam_status,2',
  33. 'yz_cat_id|有赞分类' => 'number|egt:0',
  34. 'is_support_barter|是否可退货' => 'requireIf:exam_status,1|number|in:0,1',
  35. 'good_ladder_id|商品阶梯记录id' => 'requireIf:exam_status,1|number|gt:0',
  36. 'final_price|最终售价' => 'requireIf:exam_status,1|float|elt:9999999',
  37. 'start_sale_num|有赞起售数' => 'requireIf:exam_status,1|number',
  38. 'relaComNo|关联公司' => 'require',
  39. 'distribution|配送方式' => 'require|array|max:3',
  40. ]);
  41. if ($val->check($param)) return Goodup::youzanGoodUpOnline($param['platform_youzan_id'], $param,$this->uid,$this->uname);
  42. else return error_show(1005, $val->getError());
  43. }
  44. //有赞商品重新上线
  45. public function goodupOnlineAgain()
  46. {
  47. $param = $this->request->only(['token', 'platform_youzan_id'], 'post', 'trim');
  48. $val = Validate::rule([
  49. 'platform_youzan_id|商品上线记录ID' => 'require|number|gt:0',
  50. 'token' => 'require',
  51. ]);
  52. if ($val->check($param)) return Goodup::goodupOnlineAgain($param['platform_youzan_id'], $param['token']);
  53. else return error_show(1005, $val->getError());
  54. }
  55. //商品上线详情
  56. public function getYzGoodupInfo()
  57. {
  58. $param = $this->request->filter('trim')->only(['platform_youzan_id' => '', 'skuCode' => '']);
  59. $val = Validate::rule(['platform_youzan_id|ID' => 'requireWithout:skuCode', 'skuCode|商品上线编码' => 'requireWithout:platform_youzan_id']);
  60. if ($val->check($param)) return Goodup::getYzGoodupInfo($param);
  61. else return error_show(1005, $val->getError());
  62. }
  63. //商品下线
  64. public function youzanOffline()
  65. {
  66. $param = $this->request->only(['platform_youzan_id', 'token', 'offline_reason_id', 'offline_remark' => ''], 'post', 'trim');
  67. $val = Validate::rule([
  68. 'platform_youzan_id|有赞商品上线记录id' => 'require|number|gt:0',
  69. 'offline_reason_id|商品下线原因id' => 'require|number|gt:0',
  70. 'offline_remark|商品下线备注' => 'require|max:255',
  71. 'token' => 'require',
  72. ]);
  73. if ($val->check($param)) return Goodup::youzanGoodOffline($param['platform_youzan_id'], $param);
  74. else return error_show(1005, $val->getError());
  75. }
  76. //有赞下线商品列表
  77. public function youzanOfflineList()
  78. {
  79. $param = $this->request->only(['start_date' => '', 'end_date' => '', 'creater' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
  80. return Goodup::youzanOfflineList($param);
  81. }
  82. //有赞下线商品详情
  83. public function youzanOfflineDetail()
  84. {
  85. $id = $this->request->param('id/d', 0, 'trim');
  86. return Goodup::youzanOfflineDetail($id);
  87. }
  88. //获取有赞订单列表
  89. public function getYzOrderList()
  90. {
  91. $param = $this->request->filter('trim')->only(['tid' => '', 'oid' => '', 'plat_code' => '', 'orderCode' => '', 'skuCode' => '', 'platform_name' => '', 'status' => '', 'addtime_start' => '', 'addtime_end' => '', 'page' => 1, 'size' => 15], 'post');
  92. return Order::getYzOrderList($param);
  93. }
  94. //获取有赞平台修改商品日志
  95. public function getYzUpdateLog()
  96. {
  97. $param = $this->request->only(['msg_type' => '', 'page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => ''], 'post', 'trim');
  98. $res = curl_request(config('app.yz_domain') . 'api/yz_get_youzan_update_log', $param);
  99. $res = json_decode($res, true);
  100. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  101. else return error_show(1005, $res['message']);
  102. }
  103. //获取修改商品日志,采销系统
  104. public function getUpdateGoodLog()
  105. {
  106. $param = $this->request->only(['page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => '', 'skuCode' => '', 'creater' => ''], 'post', 'trim');
  107. $res = curl_request(config('app.yz_domain') . 'api/yz_get_update_good_log_by_caixiao', $param);
  108. $res = json_decode($res, true);
  109. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  110. else return error_show(1005, $res['message']);
  111. }
  112. //有赞订单审核
  113. public function orderCheckStatus()
  114. {
  115. $param = $this->request->filter('trim')->only(['id', 'status', 'token',"fee_type"=>'', 'reason' => '']);
  116. $val = Validate::rule([
  117. 'id|订单ID' => 'require|number|gt:0',
  118. 'status|审核状态' => 'require|number|in:3,4,5,0',
  119. 'token' => 'require',
  120. "fee_type"=>"number"
  121. ]);
  122. if ($val->check($param)) return Order::checkStatus($param);
  123. else return error_show(1005, $val->getError());
  124. }
  125. //有赞订单详情
  126. public function orderDetail()
  127. {
  128. $id = $this->request->filter('trim')->post('id/d', 0);
  129. $res = curl_request(config('app.yz_domain') . 'api/yz_order_detail', ['id' => $id]);
  130. $res = json_decode($res, true);
  131. if ($res['code'] == 0) return app_show(0, '获取成功', $res['data']);
  132. else return error_show(1005, $res['message']);
  133. }
  134. //有赞订单取消记录
  135. public function closeOrderList()
  136. {
  137. $param = $this->request->filter('trim')->only(['page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => '', 'tid' => ''], 'post');
  138. $res = curl_request(config('app.yz_domain') . 'api/yz_close_order_list', $param);
  139. $res = json_decode($res, true);
  140. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  141. else return error_show(1005, $res['message']);
  142. }
  143. //收货地址修改记录
  144. public function changeAddressList()
  145. {
  146. $param = $this->request->filter('trim')->only(['page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => '', 'tid' => ''], 'post');
  147. $res = curl_request(config('app.yz_domain') . 'api/yz_get_change_address_list', $param);
  148. $res = json_decode($res, true);
  149. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  150. else return error_show(1005, $res['message']);
  151. }
  152. //订单转单失败时,重试
  153. public function orderRetry()
  154. {
  155. $param = $this->request->filter('trim')->only(['id', 'token']);
  156. $val = Validate::rule(['id|ID' => 'require|number|gt:0', 'token' => 'require']);
  157. if ($val->check($param)) {
  158. $user = GetUserInfo($param['token']);
  159. $param['uid'] = isset($user['data']['id']) ? $user['data']['id'] : 0;
  160. $param['uname'] = isset($user['data']['nickname']) ? $user['data']['nickname'] : 0;
  161. $res = curl_request(config('app.yz_domain') . 'api/yz_order_retry', $param);
  162. $res = json_decode($res, true);
  163. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  164. else return error_show(1005, $res['message']);
  165. } else return error_show(1005, $val->getError());
  166. }
  167. //订单删除
  168. public function orderDelete()
  169. {
  170. $param = $this->request->filter('trim')->only(['id', 'token']);
  171. $val = Validate::rule(['id|ID' => 'require|array|max:100', 'token' => 'require']);
  172. if ($val->check($param)) {
  173. // $user = GetUserInfo($param['token']);
  174. $param['uid'] = $this->uid;
  175. $param['uname'] = $this->uname;
  176. $res = curl_request(config('app.yz_domain') . 'api/yz_order_delete', $param);
  177. $res = json_decode($res, true);
  178. return app_show($res['code'], $res['message']);
  179. } else return error_show(1005, $val->getError());
  180. }
  181. }