123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- <?php
- namespace app\youzan\controller;
- use app\admin\controller\Base;
- use app\admin\model\Platform;use app\admin\model\PlatformYouzan;use app\youzan\logic\Cat;
- use app\youzan\logic\Order;
- use app\youzan\logic\Tag;
- use app\youzan\logic\Goodup;
- use app\youzan\model\Account;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());
- }
-
- public function goodList(){
- $param = $this->request->only([
- 'page' => 1,
- 'size' => 15,
- 'cat_id' => '',
- 'good_name' => '',
- 'skucode' => '',
- 'spucode' => '',
- 'start' => '',
- 'end' => '',
- 'is_stock' => '',
- 'good_type' => '',
- 'supplierNo' => '',
- 'companyNo' => '',
- 'creater' => '',
- 'online_creater' => '',
- 'createrid' => '',
- 'status' => '',
- 'platform_code' => '',
- 'platform_type' => 1,
- 'plat_code' => '',
- 'exam_status' => '',
- 'brand_id' => '',
- 'company_name' => '',
- 'relaComNo' => '',
- ],"post","trim");
-
- $where = [['b.is_del', '=', 0]];
- $platfrom =new Platform();
- if ($param['cat_id'] !== '') $where[] = ['a.cat_id', '=', $param['cat_id']];
- if ($param['good_name'] !== '') $where[] = ['a.good_name', 'like', '%' . $param['good_name'] . '%'];
- if ($param['skucode'] !== '') $where [] = ['b.skucode', 'like', '%' . $param['skucode'] . '%'];
- if ($param['spucode'] !== '') $where [] = ['b.spucode', 'like', '%' . $param['spucode'] . '%'];
- if ($param['start'] !== '') $where[] = ['b.addtime', '>=', date('Y-m-d H:i:s', strtotime($param['start']))];
- if ($param['end'] !== '') $where[] = ['b.addtime', '<', date('Y-m-d H:i:s', strtotime($param['end']) + 24 * 3600)];
- if ($param['is_stock'] !== '') $where[] = ['a.is_stock', '=', $param['is_stock']];
- if ($param['good_type'] !== '') $where[] = ['a.good_type', '=', $param['good_type']];
- if ($param['supplierNo'] !== '') $where[] = ['a.supplierNo', '=', $param['supplierNo']];
- if ($param['companyNo'] !== '') $where[] = ['a.companyNo', 'like', '%' . $param['companyNo'] . '%'];
- if ($param['online_creater'] !== '') $where[] = ['b.creater', 'like', '%' . $param['online_creater'] . '%'];
- if ($param['creater'] !== '') $where[] = ['a.creater', 'like', '%' . $param['creater'] . '%'];
- if ($param['createrid'] !== '') $where[] = ['a.createrid', '=', $param['createrid']];
- if ($param['status'] !== '') $where[] = ['a.status', '=', $param['status']];
- if ($param['platform_code'] !== '') $where[] = ['b.platform_id', '=', $param['platform_code']];
- if ($param['plat_code'] !== '') $where[] = ['b.plat_code', 'like', '%' . $param['plat_code'] . '%'];
- if ($param['exam_status'] !== '') $where[] = ['b.exam_status', '=', $param['exam_status']];
- if ($param['brand_id'] !== '') $where[] = ['a.brand_id', '=', $param['brand_id']];
- if($param['platform_type'] == ''){
- $platfromId = $platfrom->where(["platform_type"=>$param['platform_type'],"is_del"=>0])->column("id");
- $where[] = ['b.platform_id', 'in', $platfromId ];
- }
- if($param['relaComNo'] !== '') $where[]=['a.companyNo|a.supplierNo','=', $param['relaComNo']];
- $list = (new PlatformYouzan()) ->alias('b')
- ->leftJoin('good_basic a', 'a.spuCode=b.spuCode')
- ->field("b.id,b.platform_id,b.plat_code,b.spuCode,b.skuCode,good_img,good_name,b.exam_status status,a.cat_id,a.good_unit,a.good_type,
- a.is_exclusive,a.brand_id,a.companyNo,a.companyName company,b.creater,b.addtime,a.createrid purchase_id,a.creater purchase")
- ->where($where)->order("id desc")->paginate(["page"=>$param['page'],"list_rows"=>$param['size']]);
- $cat =new \app\admin\model\Cat();
- $Brand =new \app\admin\model\Brand();
- $unit =new \app\admin\model\Unit();
- $account = new Account();
- foreach ($list->items() as $item){
- $catinfo= $cat->where(['id'=>$item['cat_id']])->value('search','');
- $item['cat_info'] =explode("_",$catinfo);
- $item['brand_name'] =$Brand->where(["id"=>$item['brand_id']])->value("brand_name",'');
- $item['unit'] =$unit->where(["id"=>$item['good_unit']])->value("unit",'');
- $item['platform_name'] =$platfrom->where(["id"=>$item['platform_id']])->value("platform_name",'');
- $item['exclusive'] = makeExcluse($item['is_exclusive']);
- $item['is_allow_update'] = 0;
- $item['company_name'] =$account->name("account_item")->alias("a")->leftJoin("company_item b","a.itemid=b.id")
- ->where("a.account_id",$item['purchase_id'])->value("b.name");
- }
- return app_show(0, '获取成功', ['list' => $list->items(), 'count' => $list->total()]);
- }
- }
|