Index.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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', 'is_support_barter', 'good_ladder_id', 'final_price', 'token', 'start_sale_num', 'tags' => [], 'item_type' => 0, 'auto_listing_time' => '0', 'origin' => 0], '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|有赞分类' => 'requireIf:exam_status,1|number|gt: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. 'token' => 'require',
  39. ]);
  40. if ($val->check($param)) return Goodup::youzanGoodUpOnline($param['platform_youzan_id'], $param);
  41. else return error_show(1005, $val->getError());
  42. }
  43. //有赞商品重新上线
  44. public function goodupOnlineAgain()
  45. {
  46. $param = $this->request->only(['token', 'platform_youzan_id'], 'post', 'trim');
  47. $val = Validate::rule([
  48. 'platform_youzan_id|商品上线记录ID' => 'require|number|gt:0',
  49. 'token' => 'require',
  50. ]);
  51. if ($val->check($param)) return Goodup::goodupOnlineAgain($param['platform_youzan_id'], $param['token']);
  52. else return error_show(1005, $val->getError());
  53. }
  54. //商品上线详情
  55. public function getYzGoodupInfo()
  56. {
  57. $param = $this->request->filter('trim')->only(['platform_youzan_id' => '', 'skuCode' => '']);
  58. $val = Validate::rule(['platform_youzan_id|ID' => 'requireWithout:skuCode', 'skuCode|商品上线编码' => 'requireWithout:platform_youzan_id']);
  59. if ($val->check($param)) return Goodup::getYzGoodupInfo($param);
  60. else return error_show(1005, $val->getError());
  61. }
  62. //商品下线
  63. public function youzanOffline()
  64. {
  65. $param = $this->request->only(['platform_youzan_id', 'token', 'offline_reason_id', 'offline_remark' => ''], 'post', 'trim');
  66. $val = Validate::rule([
  67. 'platform_youzan_id|有赞商品上线记录id' => 'require|number|gt:0',
  68. 'offline_reason_id|商品下线原因id' => 'require|number|gt:0',
  69. 'offline_remark|商品下线备注' => 'require|max:255',
  70. 'token' => 'require',
  71. ]);
  72. if ($val->check($param)) return Goodup::youzanGoodOffline($param['platform_youzan_id'], $param);
  73. else return error_show(1005, $val->getError());
  74. }
  75. //有赞下线商品列表
  76. public function youzanOfflineList()
  77. {
  78. $param = $this->request->only(['start_date' => '', 'end_date' => '', 'creater' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
  79. return Goodup::youzanOfflineList($param);
  80. }
  81. //有赞下线商品详情
  82. public function youzanOfflineDetail()
  83. {
  84. $id = $this->request->param('id/d', 0, 'trim');
  85. return Goodup::youzanOfflineDetail($id);
  86. }
  87. //获取有赞订单列表
  88. public function getYzOrderList()
  89. {
  90. $param = $this->request->filter('trim')->only(['oid' => '', 'plat_code' => '', 'orderCode' => '', 'skuCode' => '', 'platform_name' => '', 'status' => '', 'addtime_start' => '', 'addtime_end' => '', 'page' => 1, 'size' => 15], 'post');
  91. return Order::getYzOrderList($param);
  92. }
  93. //获取有赞平台修改商品日志
  94. public function getYzUpdateLog()
  95. {
  96. $param = $this->request->only(['msg_type' => '', 'page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => ''], 'post', 'trim');
  97. $res = curl_request(config('app.yz_domain') . 'api/yz_get_youzan_update_log', $param);
  98. $res = json_decode($res, true);
  99. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  100. else return error_show(1005, $res['message']);
  101. }
  102. //获取修改商品日志,采销系统
  103. public function getUpdateGoodLog()
  104. {
  105. $param = $this->request->only(['page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => '', 'skuCode' => '', 'creater' => ''], 'post', 'trim');
  106. $res = curl_request(config('app.yz_domain') . 'api/yz_get_update_good_log_by_caixiao', $param);
  107. $res = json_decode($res, true);
  108. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  109. else return error_show(1005, $res['message']);
  110. }
  111. //有赞订单审核
  112. public function orderCheckStatus()
  113. {
  114. $param = $this->request->filter('trim')->only(['id', 'status', 'token', 'reason' => '']);
  115. $val = Validate::rule([
  116. 'id|订单ID' => 'require|number|gt:0',
  117. 'status|审核状态' => 'require|number|in:3,4,5,0', 'token' => 'require'
  118. ]);
  119. if ($val->check($param)) return Order::checkStatus($param);
  120. else return error_show(1005, $val->getError());
  121. }
  122. //有赞订单详情
  123. public function orderDetail()
  124. {
  125. $id = $this->request->filter('trim')->post('id/d', 0);
  126. $res = curl_request(config('app.yz_domain') . 'api/yz_order_detail', ['id' => $id]);
  127. $res = json_decode($res, true);
  128. if ($res['code'] == 0) return app_show(0, '获取成功', $res['data']);
  129. else return error_show(1005, $res['message']);
  130. }
  131. //有赞订单取消记录
  132. public function closeOrderList()
  133. {
  134. $param = $this->request->filter('trim')->only(['page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => '', 'tid' => ''], 'post');
  135. $res = curl_request(config('app.yz_domain') . 'api/yz_close_order_list', $param);
  136. $res = json_decode($res, true);
  137. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  138. else return error_show(1005, $res['message']);
  139. }
  140. //收货地址修改记录
  141. public function changeAddressList()
  142. {
  143. $param = $this->request->filter('trim')->only(['page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => '', 'tid' => ''], 'post');
  144. $res = curl_request(config('app.yz_domain') . 'api/yz_get_change_address_list', $param);
  145. $res = json_decode($res, true);
  146. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  147. else return error_show(1005, $res['message']);
  148. }
  149. //订单转单失败时,重试
  150. public function orderRetry()
  151. {
  152. $param = $this->request->filter('trim')->only(['id', 'token']);
  153. $val = Validate::rule(['id|ID' => 'require|number|gt:0', 'token' => 'require']);
  154. if ($val->check($param)) {
  155. $user = GetUserInfo($param['token']);
  156. $param['uid'] = isset($user['data']['id']) ? $user['data']['id'] : 0;
  157. $param['uname'] = isset($user['data']['nickname']) ? $user['data']['nickname'] : 0;
  158. $res = curl_request(config('app.yz_domain') . 'api/yz_order_retry', $param);
  159. $res = json_decode($res, true);
  160. if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
  161. else return error_show(1005, $res['message']);
  162. } else return error_show(1005, $val->getError());
  163. }
  164. }