123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <?php
- namespace app\youzan\controller;
- use app\admin\controller\Base;
- use app\youzan\logic\Cat;
- use app\youzan\logic\Order;
- use app\youzan\logic\Tag;
- use app\youzan\logic\Goodup;
- use think\facade\Validate;
- //有赞对接类
- class Index extends Base
- {
- //获取有赞的类目列表
- public function getYzCatList()
- {
- $parent_cid = $this->request->post('parent_cid/d', 0, 'trim');
- $rs = Cat::getYzCatList($parent_cid);
- return app_show(0, '请求成功', $rs);
- }
- //获取有赞的标签列表
- public function getYzTagList()
- {
- $rs = Tag::getYzTagList();
- return app_show(0, '请求成功', $rs);
- }
- //审核并将商品推送到有赞平台
- public function checkExamstatus()
- {
- $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');
- $val = Validate::rule([
- 'platform_youzan_id|商品上线记录ID' => 'require|number|gt:0',
- 'exam_status|审核状态' => 'require|number|in:1,2',
- 'reject_reason|驳回原因' => 'requireIf:exam_status,2',
- 'yz_cat_id|有赞分类' => 'number|egt:0',
- 'is_support_barter|是否可退货' => 'requireIf:exam_status,1|number|in:0,1',
- 'good_ladder_id|商品阶梯记录id' => 'requireIf:exam_status,1|number|gt:0',
- 'final_price|最终售价' => 'requireIf:exam_status,1|float|elt:9999999',
- 'start_sale_num|有赞起售数' => 'requireIf:exam_status,1|number',
- 'relaComNo|关联公司' => 'require',
- 'distribution|配送方式' => 'require|array|max:3',
- ]);
- if ($val->check($param)) return Goodup::youzanGoodUpOnline($param['platform_youzan_id'], $param,$this->uid,$this->uname);
- else return error_show(1005, $val->getError());
- }
- //有赞商品重新上线
- public function goodupOnlineAgain()
- {
- $param = $this->request->only(['token', 'platform_youzan_id'], 'post', 'trim');
- $val = Validate::rule([
- 'platform_youzan_id|商品上线记录ID' => 'require|number|gt:0',
- 'token' => 'require',
- ]);
- if ($val->check($param)) return Goodup::goodupOnlineAgain($param['platform_youzan_id'], $param['token']);
- else return error_show(1005, $val->getError());
- }
- //商品上线详情
- public function getYzGoodupInfo()
- {
- $param = $this->request->filter('trim')->only(['platform_youzan_id' => '', 'skuCode' => '']);
- $val = Validate::rule(['platform_youzan_id|ID' => 'requireWithout:skuCode', 'skuCode|商品上线编码' => 'requireWithout:platform_youzan_id']);
- if ($val->check($param)) return Goodup::getYzGoodupInfo($param);
- else return error_show(1005, $val->getError());
- }
- //商品下线
- public function youzanOffline()
- {
- $param = $this->request->only(['platform_youzan_id', 'token', 'offline_reason_id', 'offline_remark' => ''], 'post', 'trim');
- $val = Validate::rule([
- 'platform_youzan_id|有赞商品上线记录id' => 'require|number|gt:0',
- 'offline_reason_id|商品下线原因id' => 'require|number|gt:0',
- 'offline_remark|商品下线备注' => 'require|max:255',
- 'token' => 'require',
- ]);
- if ($val->check($param)) return Goodup::youzanGoodOffline($param['platform_youzan_id'], $param);
- else return error_show(1005, $val->getError());
- }
- //有赞下线商品列表
- public function youzanOfflineList()
- {
- $param = $this->request->only(['start_date' => '', 'end_date' => '', 'creater' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
- return Goodup::youzanOfflineList($param);
- }
- //有赞下线商品详情
- public function youzanOfflineDetail()
- {
- $id = $this->request->param('id/d', 0, 'trim');
- return Goodup::youzanOfflineDetail($id);
- }
- //获取有赞订单列表
- public function getYzOrderList()
- {
- $param = $this->request->filter('trim')->only(['tid' => '', 'oid' => '', 'plat_code' => '', 'orderCode' => '', 'skuCode' => '', 'platform_name' => '', 'status' => '', 'addtime_start' => '', 'addtime_end' => '', 'page' => 1, 'size' => 15], 'post');
- return Order::getYzOrderList($param);
- }
- //获取有赞平台修改商品日志
- public function getYzUpdateLog()
- {
- $param = $this->request->only(['msg_type' => '', 'page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => ''], 'post', 'trim');
- $res = curl_request(config('app.yz_domain') . 'api/yz_get_youzan_update_log', $param);
- $res = json_decode($res, true);
- if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
- else return error_show(1005, $res['message']);
- }
- //获取修改商品日志,采销系统
- public function getUpdateGoodLog()
- {
- $param = $this->request->only(['page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => '', 'skuCode' => '', 'creater' => ''], 'post', 'trim');
- $res = curl_request(config('app.yz_domain') . 'api/yz_get_update_good_log_by_caixiao', $param);
- $res = json_decode($res, true);
- if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
- else return error_show(1005, $res['message']);
- }
- //有赞订单审核
- public function orderCheckStatus()
- {
- $param = $this->request->filter('trim')->only(['id', 'status', 'token',"fee_type"=>'', 'reason' => '']);
- $val = Validate::rule([
- 'id|订单ID' => 'require|number|gt:0',
- 'status|审核状态' => 'require|number|in:3,4,5,0',
- 'token' => 'require',
- "fee_type"=>"number"
- ]);
- if ($val->check($param)) return Order::checkStatus($param);
- else return error_show(1005, $val->getError());
- }
- //有赞订单详情
- public function orderDetail()
- {
- $id = $this->request->filter('trim')->post('id/d', 0);
- $res = curl_request(config('app.yz_domain') . 'api/yz_order_detail', ['id' => $id]);
- $res = json_decode($res, true);
- if ($res['code'] == 0) return app_show(0, '获取成功', $res['data']);
- else return error_show(1005, $res['message']);
- }
- //有赞订单取消记录
- public function closeOrderList()
- {
- $param = $this->request->filter('trim')->only(['page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => '', 'tid' => ''], 'post');
- $res = curl_request(config('app.yz_domain') . 'api/yz_close_order_list', $param);
- $res = json_decode($res, true);
- if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
- else return error_show(1005, $res['message']);
- }
- //收货地址修改记录
- public function changeAddressList()
- {
- $param = $this->request->filter('trim')->only(['page' => 1, 'size' => 15, 'start_date' => '', 'end_date' => '', 'tid' => ''], 'post');
- $res = curl_request(config('app.yz_domain') . 'api/yz_get_change_address_list', $param);
- $res = json_decode($res, true);
- if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
- else return error_show(1005, $res['message']);
- }
- //订单转单失败时,重试
- public function orderRetry()
- {
- $param = $this->request->filter('trim')->only(['id', 'token']);
- $val = Validate::rule(['id|ID' => 'require|number|gt:0', 'token' => 'require']);
- if ($val->check($param)) {
- $user = GetUserInfo($param['token']);
- $param['uid'] = isset($user['data']['id']) ? $user['data']['id'] : 0;
- $param['uname'] = isset($user['data']['nickname']) ? $user['data']['nickname'] : 0;
- $res = curl_request(config('app.yz_domain') . 'api/yz_order_retry', $param);
- $res = json_decode($res, true);
- if ($res['code'] == 0) return app_show(0, '请求成功', $res['data']);
- else return error_show(1005, $res['message']);
- } else return error_show(1005, $val->getError());
- }
- //订单删除
- public function orderDelete()
- {
- $param = $this->request->filter('trim')->only(['id', 'token']);
- $val = Validate::rule(['id|ID' => 'require|array|max:100', 'token' => 'require']);
- if ($val->check($param)) {
- // $user = GetUserInfo($param['token']);
- $param['uid'] = $this->uid;
- $param['uname'] = $this->uname;
- $res = curl_request(config('app.yz_domain') . 'api/yz_order_delete', $param);
- $res = json_decode($res, true);
- return app_show($res['code'], $res['message']);
- } else return error_show(1005, $val->getError());
- }
- }
|