提交 8f36b66e authored 作者: 窦斌's avatar 窦斌

edit

上级 159734b6
...@@ -25,31 +25,58 @@ class JdOrderApiController extends BaseController ...@@ -25,31 +25,58 @@ class JdOrderApiController extends BaseController
public function getOrderByJd( ){ public function getOrderByJd( ){
$startDate = date("Y-m-d H:i:s",strtotime(" -6 minute".date("Y-m-d H:i:s"))); $startDate = date("Y-m-d H:i:s",strtotime(" -6 minute".date("Y-m-d H:i:s")));
$endDate = date("Y-m-d H:i:s"); $endDate = date("Y-m-d H:i:s");
$url = "http://116.196.75.172/index.php/SaasApiGetOrder/index?startDate=".$startDate."&endDate=".$endDate."&status=300"; $url_mobile = "http://116.196.75.172/index.php/GetOrder/getmobilelist";//出库
$url = "http://116.196.75.172/index.php/SaasApiGetOrder/omnicOrderList?startDate=".$startDate."&endDate=".$endDate."&status=300";
$token = DB::table('jdpop_token')->where('status',1)->where('type',2)->select('app_key','app_secret','access_token','pt_id','auth_key')->get()->toarray(); $token = DB::table('jdpop_token')->where('status',1)->where('type',2)->select('app_key','app_secret','access_token','pt_id','auth_key')->get()->toarray();
foreach($token as $k => $vs) { foreach($token as $k => $vs) {
$appKey = $vs['app_key'];
$accessToken = $vs['access_token'];
$appSecret = $vs['app_secret'];
$urls = $url."&authKey=".$vs['auth_key']."&access_token=".$vs['access_token']."&app_key=".$vs['app_key']."&app_secret=".$vs['app_secret']; $urls = $url."&authKey=".$vs['auth_key']."&access_token=".$vs['access_token']."&app_key=".$vs['app_key']."&app_secret=".$vs['app_secret'];
$company_id = Pt::where('id',$vs['pt_id'])->value('company_id'); $company_id = Pt::where('id',$vs['pt_id'])->value('company_id');
// echo $urls; // echo $urls;
$res = $this->http_get($urls); $res = $this->http_get($urls);
$ip = $_SERVER["REMOTE_ADDR"]; $ip = $_SERVER["REMOTE_ADDR"];
$data = json_decode($res, true); $data = json_decode($res, true);
// dump($data);
$pt_id = $vs['pt_id']; $pt_id = $vs['pt_id'];
CommonService::addLog('获取订单', $urls.'---'.$res, $vs['pt_id'], 'JdOrderApi-getOrder'); CommonService::addLog('获取订单', $urls.'---'.$res, $vs['pt_id'], 'JdOrderApi-getOrder');
$result = $data['jingdong_omnic_order_getorderlist_responce']['result']; $result = $data['jingdong_omnic_order_query_orderList_responce']['result'];
$result = json_decode($result, true);
// dump($result['success']);
if ($result['success'] == true) { if ($result['success'] == true) {
$order_data = $result['data']; $order_data = $result['data'];
if (!empty($order_data)) { if (!empty($order_data)) {
$arr = []; $arr = [];
$arr_goods = []; $arr_goods = [];
// dd($order_data);
if (isset($order_data['data'])) { if (isset($order_data['data'])) {
$order_data = $order_data['data']; $order_data = $order_data['data'];
// dd($order_data); $orderInfos=[];
// dump($order_data); $num = 0;
foreach($order_data as $kks => $vks){
if(!empty($vks['orderShip']['oaid'])) {
$orderInfos[$num]['orderId'] = $vks['orderInfo']['salesChannelOrderId'];
$orderInfos[$num]['oaid'] = $vks['orderShip']['oaid'];
$num++;
}
}
if(!empty($orderInfos)){
$poss['appKey'] = $appKey;
$poss['accessToken'] = $accessToken;
$poss['appSecret'] = $appSecret;
$poss['orderInfos'] = json_encode($orderInfos);
$user_data=CommonService::requestPost('http://zptzchat.bluearp.com/m/index.php/GetUserDataApi/getOaidDecrypt',$poss);
$user_data = json_decode($user_data,true);
if($user_data['jingdong_jos_order_oaid_decrypt_responce']['returnType']['code']==200){
$user_data = $user_data['jingdong_jos_order_oaid_decrypt_responce']['returnType']['data'];
$user_datas = [];
foreach($user_data as $ks => $vs){
$user_datas[$vs['orderId']] = $vs;
}
if(!empty($user_datas)){
foreach($order_data as $ka => $va){
$order_data[$ka]['orderShip']['user_data_dou'] = isset($user_datas[$va['orderInfo']['salesChannelOrderId']])?$user_datas[$va['orderInfo']['salesChannelOrderId']]:'';
}
}
}
}
foreach ($order_data as $kkk => $vvv) { foreach ($order_data as $kkk => $vvv) {
if ($vvv['orderDetailList']) { if ($vvv['orderDetailList']) {
$sku_ids = array_unique(array_column($vvv['orderDetailList'], 'skuId')); $sku_ids = array_unique(array_column($vvv['orderDetailList'], 'skuId'));
...@@ -80,13 +107,10 @@ class JdOrderApiController extends BaseController ...@@ -80,13 +107,10 @@ class JdOrderApiController extends BaseController
$exsit = Orders::where('order_num', $vvv['orderInfo']['salesChannelOrderId'])->value('id'); $exsit = Orders::where('order_num', $vvv['orderInfo']['salesChannelOrderId'])->value('id');
//存订单 //存订单
$eisit_jd = DB::table('jd_proprietary')->where('order_id', $vvv['orderInfo']['salesChannelOrderId'])->value('id'); $eisit_jd = DB::table('jd_proprietary')->where('order_id', $vvv['orderInfo']['salesChannelOrderId'])->value('id');
if (!$exsit && !$eisit_jd) { if ($exsit || !$eisit_jd) {
$resjdgoods = DB::table('jdgoods')->where("order_id", $vvv['orderInfo']['salesChannelOrderId'])->value('id'); $resjdgoods = DB::table('jdgoods')->where("order_id", $vvv['orderInfo']['salesChannelOrderId'])->value('id');
$sys_num = 'L' . date("YmdHis") . str_pad(rand(0, 999), 3, '0', STR_PAD_LEFT); $sys_num = 'L' . date("YmdHis") . str_pad(rand(0, 999), 3, '0', STR_PAD_LEFT);
foreach ($vvv['orderDetailList'] as $k => $v) { foreach ($vvv['orderDetailList'] as $k => $v) {
// dd($v);
// dump($arr);
//存商品 //存商品
//`gone_jdgoods` (`order_id`,`pt_id`,`sku_id`,`sku_name`,`item_total`,`jd_price`,`jd_cost`) //`gone_jdgoods` (`order_id`,`pt_id`,`sku_id`,`sku_name`,`item_total`,`jd_price`,`jd_cost`)
if (!$resjdgoods) { if (!$resjdgoods) {
...@@ -136,12 +160,70 @@ class JdOrderApiController extends BaseController ...@@ -136,12 +160,70 @@ class JdOrderApiController extends BaseController
$orders[$kkk]['skb_bh'] = $vvv['orderInfo']['salesChannelOrderId']; $orders[$kkk]['skb_bh'] = $vvv['orderInfo']['salesChannelOrderId'];
$orders[$kkk]['pt_id'] = $pt_id; $orders[$kkk]['pt_id'] = $pt_id;
$orders[$kkk]['ser_type'] = 1;//服务类型:1上门安装,2到店服务 $orders[$kkk]['ser_type'] = 1;//服务类型:1上门安装,2到店服务
$orders[$kkk]['shr_name'] = $vvv['orderShip']['consignee'] ?? '空'; if(isset($vvv['orderShip']['user_data_dou'])){
$orders[$kkk]['shr_phone'] = $vvv['consigneePhone'] ?? $vvv['orderShip']['consigneeMobile'];//$vv['consigneeInfo']['telephone'];// $fullname = $vvv['orderShip']['user_data_dou']['customerName']??$vvv['orderShip']['consignee'];
if(mb_strlen($fullname, 'UTF-8')>30){
$fullname = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$vvv['orderShip']['consigneeEnc']);
if(strpos($fullname,'<body>' )!==false){
$exs_code = DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->value('id');
if($exs_code){
DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->update(['name_code'=>$vvv['orderShip']['consigneeEnc']]);
}else{
DB::table('jdpop_encode')->insert(['order_id'=>$vvv['orderInfo']['salesChannelOrderId'],'pt_id'=>$pt_id,'name_code'=>$vvv['orderShip']['consigneeEnc']]);
}
$fullname = $vvv['orderShip']['consignee'];
}
}
}else {
$fullname = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$vvv['orderShip']['consigneeEnc']);
if(strpos($fullname,'<body>' )!==false){
$exs_code = DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->value('id');
if($exs_code){
DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->update(['name_code'=>$vvv['orderShip']['consigneeEnc']]);
}else{
DB::table('jdpop_encode')->insert(['order_id'=>$vvv['orderInfo']['salesChannelOrderId'],'pt_id'=>$pt_id,'name_code'=>$vvv['orderShip']['consigneeEnc']]);
}
$fullname = $vvv['orderShip']['consignee'];
}
}
$orders[$kkk]['shr_name'] = $fullname;
if(isset($vvv['orderShip']['user_data_dou'])){
$tel = $vvv['orderShip']['user_data_dou']['consMobilePhone']??$vvv['orderShip']['consigneePhone'];
if(mb_strlen($tel, 'UTF-8')>20){
$tel = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$tel);
if(strpos($tel,'<body>' )!==false){
$tel = $vvv['orderShip']['consigneePhone'];
}
}
}else {
$tel = $this->request_post($url_mobile,['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret,'customOrderId'=>$vvv['orderInfo']['salesChannelOrderId']]);//同步手机号
}
$orders[$kkk]['shr_phone'] = $tel;//$vv['consigneeInfo']['telephone'];//
$orders[$kkk]['shr_sheng'] = $vvv['orderShip']['addressLevel1Name'];// $orders[$kkk]['shr_sheng'] = $vvv['orderShip']['addressLevel1Name'];//
$orders[$kkk]['shr_shi'] = $vvv['orderShip']['addressLevel2Name'];// $orders[$kkk]['shr_shi'] = $vvv['orderShip']['addressLevel2Name'];//
$orders[$kkk]['shr_xian'] = $vvv['orderShip']['addressLevel3Name'];// $orders[$kkk]['shr_xian'] = $vvv['orderShip']['addressLevel3Name'];//
$orders[$kkk]['shr_adress'] = $vvv['orderShip']['deliveryAddress'];// if(isset($vvv['orderShip']['user_data_dou'])){
$fullAddress = $vvv['orderShip']['user_data_dou']['address']??$vvv['orderShip']['deliveryAddress'];
if(!preg_match('/\p{Han}/u', $fullAddress)){
$fullAddress = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$fullAddress);
if(strpos($fullAddress,'<body>' )!==false){
$fullAddress = $vvv['orderShip']['deliveryAddress'];
}
}
}else {
$fullAddress = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$vvv['orderShip']['deliveryAddressEnc']);
if(strpos($fullAddress,'<body>' )!==false){
$exs_code = DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->value('id');
if($exs_code){
DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->update(['name_code'=>$vvv['orderShip']['deliveryAddressEnc']]);
}else{
DB::table('jdpop_encode')->insert(['order_id'=>$vvv['orderInfo']['salesChannelOrderId'],'pt_id'=>$pt_id,'name_code'=>$vvv['orderShip']['deliveryAddressEnc']]);
}
$fullAddress = $vvv['orderShip']['deliveryAddress'];
}
}
$orders[$kkk]['shr_adress'] = $fullAddress;//
$orders[$kkk]['shr_other'] = '接单后10分钟内务必联系客户核实车型跟安装时间!不断电安装、如果无法完成 请立刻反馈我们处理~!'; $orders[$kkk]['shr_other'] = '接单后10分钟内务必联系客户核实车型跟安装时间!不断电安装、如果无法完成 请立刻反馈我们处理~!';
$orders[$kkk]['car_audit'] = 2;//1:新订单;2:可派单;3:处理中 $orders[$kkk]['car_audit'] = 2;//1:新订单;2:可派单;3:处理中
$orders[$kkk]['order_type'] = 1;//订单类型:1:普通;20加急;10:夜间 $orders[$kkk]['order_type'] = 1;//订单类型:1:普通;20加急;10:夜间
...@@ -155,7 +237,6 @@ class JdOrderApiController extends BaseController ...@@ -155,7 +237,6 @@ class JdOrderApiController extends BaseController
$session['admin_acc'] = '系统录入'; $session['admin_acc'] = '系统录入';
$session['id'] = 1133; $session['id'] = 1133;
$session['company_id'] = $company_id; $session['company_id'] = $company_id;
// dd($orders[$kkk]);
$return = OrderaddService::addOrder($orders[$kkk], $session, $ip); $return = OrderaddService::addOrder($orders[$kkk], $session, $ip);
CommonService::addLog('添加定单', json_encode($return), $vvv['orderInfo']['salesChannelOrderId'], 'jdAPI_addOrder'); CommonService::addLog('添加定单', json_encode($return), $vvv['orderInfo']['salesChannelOrderId'], 'jdAPI_addOrder');
if ($return['ErrorCode'] == 1 && $company_id!=14) { if ($return['ErrorCode'] == 1 && $company_id!=14) {
...@@ -319,7 +400,7 @@ class JdOrderApiController extends BaseController ...@@ -319,7 +400,7 @@ class JdOrderApiController extends BaseController
public function getOrderCancelByJd( ){ public function getOrderCancelByJd( ){
$startDate = date("Y-m-d H:i:s",strtotime(" -2880 minute".date("Y-m-d H:i:s"))); $startDate = date("Y-m-d H:i:s",strtotime(" -2880 minute".date("Y-m-d H:i:s")));
$endDate = date("Y-m-d H:i:s"); $endDate = date("Y-m-d H:i:s");
$url = "http://116.196.75.172/index.php/SaasApiGetOrder/index?startDate=".$startDate."&endDate=".$endDate."&status=204"; $url = "http://116.196.75.172/index.php/SaasApiGetOrder/omnicOrderList?startDate=".$startDate."&endDate=".$endDate."&status=204";
$token = DB::table('jdpop_token')->where('status',1)->where('type',2)->where('pt_id',33)->select('app_key','app_secret','access_token','pt_id','auth_key')->get()->toarray(); $token = DB::table('jdpop_token')->where('status',1)->where('type',2)->where('pt_id',33)->select('app_key','app_secret','access_token','pt_id','auth_key')->get()->toarray();
foreach($token as $k => $vs) { foreach($token as $k => $vs) {
$urls = $url."&authKey=".$vs['auth_key']."&access_token=".$vs['access_token']."&app_key=".$vs['app_key']."&app_secret=".$vs['app_secret']; $urls = $url."&authKey=".$vs['auth_key']."&access_token=".$vs['access_token']."&app_key=".$vs['app_key']."&app_secret=".$vs['app_secret'];
...@@ -331,8 +412,7 @@ class JdOrderApiController extends BaseController ...@@ -331,8 +412,7 @@ class JdOrderApiController extends BaseController
// dump($data); // dump($data);
$pt_id = $vs['pt_id']; $pt_id = $vs['pt_id'];
CommonService::addLog('获取取消订单', $urls.'---'.$res, $vs['pt_id'], 'JdOrderApi-getOrderCancelByJd'); CommonService::addLog('获取取消订单', $urls.'---'.$res, $vs['pt_id'], 'JdOrderApi-getOrderCancelByJd');
$result = $data['jingdong_omnic_order_getorderlist_responce']['result']; $result = $data['jingdong_omnic_order_query_orderList_responce']['result'];
$result = json_decode($result, true);
if ($result['success'] == true) { if ($result['success'] == true) {
$order_data = $result['data']; $order_data = $result['data'];
if (!empty($order_data)) { if (!empty($order_data)) {
...@@ -380,6 +460,7 @@ class JdOrderApiController extends BaseController ...@@ -380,6 +460,7 @@ class JdOrderApiController extends BaseController
$session['id'] = '1133'; $session['id'] = '1133';
$session['admin_acc'] = '系统操作'; $session['admin_acc'] = '系统操作';
$session['admin_groupnew'] = 7; $session['admin_groupnew'] = 7;
$session['company_id'] = $company_id;
$rea = OrderService::lockOrder($refund, $session, '39.105.188.64'); $rea = OrderService::lockOrder($refund, $session, '39.105.188.64');
} else { } else {
$rea = '无订单商品'; $rea = '无订单商品';
...@@ -398,4 +479,23 @@ class JdOrderApiController extends BaseController ...@@ -398,4 +479,23 @@ class JdOrderApiController extends BaseController
} }
} }
} }
/**
* @name 解密
* @param $data
* @return string
* @author du
* @date 2024/3/29
* @Time: 9:54
*/
public function decrypt($data,$str,$order_num = ''){
if(preg_match("/[\x7f-\xff]/",$str)){
return $str;
}
$data['str'] = str_replace('+', '%2B', $str);
$decrypt_data = json_encode($data);
$url = "http://jm.bluearp.com/jd/jdDecrypt?data=".$decrypt_data;
$res = (string)CommonService::https_request($url);
CommonService::addLog('URL', $order_num.'---'.$url.'----'.$res, 111,'url');
return $res;
}
} }
...@@ -17,10 +17,12 @@ use App\Http\Controllers\Api\SynJdRapidController; ...@@ -17,10 +17,12 @@ use App\Http\Controllers\Api\SynJdRapidController;
use App\Http\Controllers\BaseController; use App\Http\Controllers\BaseController;
use App\Http\Controllers\Orders\AotuorderController; use App\Http\Controllers\Orders\AotuorderController;
use App\Models\Admin; use App\Models\Admin;
use App\Models\JdBound;
use App\Models\OrderList; use App\Models\OrderList;
use App\Models\OrderMsg; use App\Models\OrderMsg;
use App\Models\OrderRejected; use App\Models\OrderRejected;
use App\Models\Orders; use App\Models\Orders;
use App\Models\PjGoods;
use App\Models\Pt; use App\Models\Pt;
use App\Models\RechargeOrder; use App\Models\RechargeOrder;
use App\Models\User; use App\Models\User;
...@@ -55,7 +57,7 @@ class MyTestController extends BaseController ...@@ -55,7 +57,7 @@ class MyTestController extends BaseController
if(empty($input['method'])){ if(empty($input['method'])){
return $this->error('缺少必要参数1',ErrorInc::FAILED_PARAM); return $this->error('缺少必要参数1',ErrorInc::FAILED_PARAM);
} }
$api=['getSerStatistics','getSerStatisticsDetail','BasicExport','addOrderData','addOrderDatas','sysServiseCenter','getJdOrderStatus','getDataDecrypt','calculateOrderPrice']; $api=['getSerStatistics','getSerStatisticsDetail','BasicExport','addOrderData','addOrderDatas','sysServiseCenter','getJdOrderStatus','getDataDecrypt','calculateOrderPrice','omnicOrderList'];
if(!in_array($input['method'],$api)){ if(!in_array($input['method'],$api)){
return $this->error('接口不参数异常',ErrorInc::INVALID_PARAM,$input); return $this->error('接口不参数异常',ErrorInc::INVALID_PARAM,$input);
}else { }else {
...@@ -850,7 +852,7 @@ class MyTestController extends BaseController ...@@ -850,7 +852,7 @@ class MyTestController extends BaseController
$data['str'] = str_replace('+', '%2B', $str); $data['str'] = str_replace('+', '%2B', $str);
$decrypt_data = json_encode($data); $decrypt_data = json_encode($data);
$url = "http://jm.bluearp.com/jd/jdDecrypt?data=".$decrypt_data; $url = "http://jm.bluearp.com/jd/jdDecrypt?data=".$decrypt_data;
$res = (string)$this->https_request($url); $res = (string)CommonService::https_request($url);
CommonService::addLog('URL', $order_num.'---'.$url.'----'.$res, 111,'url'); CommonService::addLog('URL', $order_num.'---'.$url.'----'.$res, 111,'url');
return $res; return $res;
} }
...@@ -1367,4 +1369,280 @@ class MyTestController extends BaseController ...@@ -1367,4 +1369,280 @@ class MyTestController extends BaseController
} }
} }
/**|---------------------------------------------------------------------------------
* @name 获取京东全渠道订单
* @retrun \Illuminate\Http\JsonResponse /multitype:array
* @author dou 2025/9/30 14:22
* |---------------------------------------------------------------------------------
*/
public function omnicOrderList ( $input ){
$startDate = date("Y-m-d H:i:s",strtotime(" -1360 minute".date("Y-m-d H:i:s")));
$endDate = date("Y-m-d H:i:s");
$url_mobile = "http://116.196.75.172/index.php/GetOrder/getmobilelist";//出库
$url = "http://116.196.75.172/index.php/SaasApiGetOrder/omnicOrderList?startDate=".$startDate."&endDate=".$endDate."&status=300";
$token = DB::table('jdpop_token')->where('status',1)->where('type',2)->select('app_key','app_secret','access_token','pt_id','auth_key')->get()->toarray();
foreach($token as $k => $vs) {
$appKey = $vs['app_key'];
$accessToken = $vs['access_token'];
$appSecret = $vs['app_secret'];
$urls = $url."&authKey=".$vs['auth_key']."&access_token=".$vs['access_token']."&app_key=".$vs['app_key']."&app_secret=".$vs['app_secret'];
$company_id = Pt::where('id',$vs['pt_id'])->value('company_id');
// echo $urls;
$res = $this->http_get($urls);
$ip = $_SERVER["REMOTE_ADDR"];
$data = json_decode($res, true);
$pt_id = $vs['pt_id'];
CommonService::addLog('获取订单', $urls.'---'.$res, $vs['pt_id'], 'JdOrderApi-getOrder');
$result = $data['jingdong_omnic_order_query_orderList_responce']['result'];
if ($result['success'] == true) {
$order_data = $result['data'];
if (!empty($order_data)) {
$arr = [];
$arr_goods = [];
if (isset($order_data['data'])) {
$order_data = $order_data['data'];
$orderInfos=[];
$num = 0;
foreach($order_data as $kks => $vks){
if(!empty($vks['orderShip']['oaid'])) {
$orderInfos[$num]['orderId'] = $vks['orderInfo']['salesChannelOrderId'];
$orderInfos[$num]['oaid'] = $vks['orderShip']['oaid'];
$num++;
}
}
if(!empty($orderInfos)){
$poss['appKey'] = $appKey;
$poss['accessToken'] = $accessToken;
$poss['appSecret'] = $appSecret;
$poss['orderInfos'] = json_encode($orderInfos);
$user_data=CommonService::requestPost('http://zptzchat.bluearp.com/m/index.php/GetUserDataApi/getOaidDecrypt',$poss);
$user_data = json_decode($user_data,true);
if($user_data['jingdong_jos_order_oaid_decrypt_responce']['returnType']['code']==200){
$user_data = $user_data['jingdong_jos_order_oaid_decrypt_responce']['returnType']['data'];
$user_datas = [];
foreach($user_data as $ks => $vs){
$user_datas[$vs['orderId']] = $vs;
}
if(!empty($user_datas)){
foreach($order_data as $ka => $va){
$order_data[$ka]['orderShip']['user_data_dou'] = isset($user_datas[$va['orderInfo']['salesChannelOrderId']])?$user_datas[$va['orderInfo']['salesChannelOrderId']]:'';
}
}
}
}
foreach ($order_data as $kkk => $vvv) {
if ($vvv['orderDetailList']) {
$sku_ids = array_unique(array_column($vvv['orderDetailList'], 'skuId'));
$goods_ids = JdBound::whereIn('sku_id', $sku_ids)->pluck('goods_id', 'sku_id');
$goods_ids = CommonService::dataToArray($goods_ids);
if (empty($goods_ids)) {
CommonService::addLog('SKU_all_no', json_encode($sku_ids), $vvv['orderInfo']['salesChannelOrderId'], 'SKU_all_no');
continue;
}
$goods_idss = JdBound::whereIn('sku_id', $sku_ids)->pluck('goods_id');
$goods_idss = CommonService::dataToArray($goods_idss);
if (empty($goods_idss)) {
continue;
}
$goods = PjGoods::whereIn('pg_id', $goods_idss)->select('pg_id', 'brand_name', 'pg_series', 'version', 'goods_pic_path', 'national_version')->get()->toarray();
if ($goods) {
$brand_name = array_unique(array_column($goods, 'brand_name'));
} else {
CommonService::addLog('SKU_all_no', json_encode($sku_ids), $vvv['orderInfo']['salesChannelOrderId'], 'nogood');
continue;
}
$goods = CommonService::jointArrayKey($goods, 'pg_id');
if (count($goods) < count($vvv['orderDetailList'])) {
CommonService::addLog('SKU_all_no', json_encode($sku_ids), $vvv['orderInfo']['salesChannelOrderId'], 'SKU_all_no');
continue;
}
$exsit = Orders::where('order_num', $vvv['orderInfo']['salesChannelOrderId'])->value('id');
//存订单
$eisit_jd = DB::table('jd_proprietary')->where('order_id', $vvv['orderInfo']['salesChannelOrderId'])->value('id');
if ($exsit || !$eisit_jd) {
$resjdgoods = DB::table('jdgoods')->where("order_id", $vvv['orderInfo']['salesChannelOrderId'])->value('id');
$sys_num = 'L' . date("YmdHis") . str_pad(rand(0, 999), 3, '0', STR_PAD_LEFT);
foreach ($vvv['orderDetailList'] as $k => $v) {
//存商品
//`gone_jdgoods` (`order_id`,`pt_id`,`sku_id`,`sku_name`,`item_total`,`jd_price`,`jd_cost`)
if (!$resjdgoods) {
if (in_array($vvv['orderInfo']['salesChannelOrderId'], array_column($arr_goods, 'order_id'))) {
unset($arr_goods[$k]);
// echo 1;echo '---'.$v['orderId'].'---';
}
$arr_goods[$k]['order_id'] = $vvv['orderInfo']['salesChannelOrderId'];
$arr_goods[$k]['pt_id'] = $pt_id;
$arr_goods[$k]['sku_id'] = $v['skuId'];
$arr_goods[$k]['item_total'] = $v['num'];
$arr_goods[$k]['jd_price'] = $v['skuAmount'];
$arr_goods[$k]['jd_cost'] = $v['skuPrice'];
$arr_goods[$k]['sku_name'] = $v['skuName'];
DB::table('jdgoods')->insert($arr_goods[$k]);
unset($arr_goods[$k]);
}
$goodid = $goods_ids[$v['skuId']];
if ($goodid) {
$goods_res = $goods[$goodid];
// dd($goods_res);
if ($goods_res['pg_series'] == '') {
$type = $goods_res['version'];
} else {
$type = $goods_res['pg_series'] . "-" . $goods_res['version'];
}
$goods_name = $goods_name . $goods_res['brand_name'] . "," . $type . "," . $goods_res['general_version'] . ",";
$good_brand[] = $goods_res['brand_name'];
$orderMsgData[$k]['goods_id'] = $goodid;
$orderMsgData[$k]['goods_name'] = $goods_res['brand_name'] . "-" . $type;
$orderMsgData[$k]['goods_price'] = $v['skuPrice'];//实收/商品单价
$orderMsgData[$k]['goods_paid'] = $v['skuPrice'];
$orderMsgData[$k]['goods_num'] = $v['num'];
$orderMsgData[$k]['goods_brand'] = $goods_res['brand_name'];
$orderMsgData[$k]['goods_number'] = $type;
$orderMsgData[$k]['cd_id'] = 1;
} else {
//未绑定SKU
CommonService::addLog('未绑定SKU', $v['skuId'], $vvv['orderInfo']['salesChannelOrderId'], 'jdAPI_sku');
continue;
}
}
$orders[$kkk]['sys_bh'] = $sys_num;
$orders[$kkk]['skb_bh'] = $vvv['orderInfo']['salesChannelOrderId'];
$orders[$kkk]['pt_id'] = $pt_id;
$orders[$kkk]['ser_type'] = 1;//服务类型:1上门安装,2到店服务
if(isset($vvv['orderShip']['user_data_dou'])){
$fullname = $vvv['orderShip']['user_data_dou']['customerName']??$vvv['orderShip']['consignee'];
if(mb_strlen($fullname, 'UTF-8')>30){
$fullname = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$vvv['orderShip']['consigneeEnc']);
if(strpos($fullname,'<body>' )!==false){
$exs_code = DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->value('id');
if($exs_code){
DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->update(['name_code'=>$vvv['orderShip']['consigneeEnc']]);
}else{
DB::table('jdpop_encode')->insert(['order_id'=>$vvv['orderInfo']['salesChannelOrderId'],'pt_id'=>$pt_id,'name_code'=>$vvv['orderShip']['consigneeEnc']]);
}
$fullname = $vvv['orderShip']['consignee'];
}
}
}else {
$fullname = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$vvv['orderShip']['consigneeEnc']);
if(strpos($fullname,'<body>' )!==false){
$exs_code = DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->value('id');
if($exs_code){
DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->update(['name_code'=>$vvv['orderShip']['consigneeEnc']]);
}else{
DB::table('jdpop_encode')->insert(['order_id'=>$vvv['orderInfo']['salesChannelOrderId'],'pt_id'=>$pt_id,'name_code'=>$vvv['orderShip']['consigneeEnc']]);
}
$fullname = $vvv['orderShip']['consignee'];
}
}
$orders[$kkk]['shr_name'] = $fullname;
if(isset($vvv['orderShip']['user_data_dou'])){
$tel = $vvv['orderShip']['user_data_dou']['consMobilePhone']??$vvv['orderShip']['consigneePhone'];
if(mb_strlen($tel, 'UTF-8')>20){
$tel = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$tel);
if(strpos($tel,'<body>' )!==false){
$tel = $vvv['orderShip']['consigneePhone'];
}
}
}else {
$tel = $this->request_post($url_mobile,['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret,'customOrderId'=>$vvv['orderInfo']['salesChannelOrderId']]);//同步手机号
}
$orders[$kkk]['shr_phone'] = $tel;//$vv['consigneeInfo']['telephone'];//
$orders[$kkk]['shr_sheng'] = $vvv['orderShip']['addressLevel1Name'];//
$orders[$kkk]['shr_shi'] = $vvv['orderShip']['addressLevel2Name'];//
$orders[$kkk]['shr_xian'] = $vvv['orderShip']['addressLevel3Name'];//
if(isset($vvv['orderShip']['user_data_dou'])){
$fullAddress = $vvv['orderShip']['user_data_dou']['address']??$vvv['orderShip']['deliveryAddress'];
if(!preg_match('/\p{Han}/u', $fullAddress)){
$fullAddress = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$fullAddress);
if(strpos($fullAddress,'<body>' )!==false){
$fullAddress = $vvv['orderShip']['deliveryAddress'];
}
}
}else {
$fullAddress = $this->decrypt(['accessToken'=>$accessToken,'appKey'=>$appKey,'appSecret'=>$appSecret],$vvv['orderShip']['deliveryAddressEnc']);
if(strpos($fullAddress,'<body>' )!==false){
$exs_code = DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->value('id');
if($exs_code){
DB::table('jdpop_encode')->where('order_id',$vvv['orderInfo']['salesChannelOrderId'])->update(['name_code'=>$vvv['orderShip']['deliveryAddressEnc']]);
}else{
DB::table('jdpop_encode')->insert(['order_id'=>$vvv['orderInfo']['salesChannelOrderId'],'pt_id'=>$pt_id,'name_code'=>$vvv['orderShip']['deliveryAddressEnc']]);
}
$fullAddress = $vvv['orderShip']['deliveryAddress'];
}
}
$orders[$kkk]['shr_adress'] = $fullAddress;//
$orders[$kkk]['shr_other'] = '接单后10分钟内务必联系客户核实车型跟安装时间!不断电安装、如果无法完成 请立刻反馈我们处理~!';
$orders[$kkk]['car_audit'] = 2;//1:新订单;2:可派单;3:处理中
$orders[$kkk]['order_type'] = 1;//订单类型:1:普通;20加急;10:夜间
$orders[$kkk]['order_time'] = date('Y-m-d H:i:s', $v['createTime'] / 1000);
$orders[$kkk]['pay_type'] = 1;//支付方式:1在线支付;2货到付款 $input['shr_other']
$orders[$kkk]['goods'] = $orderMsgData;
$orders[$kkk]['shr_other'] = $vvv['orderInfo']['promiseMsg'];
$orders[$kkk]['clientAccount'] = $vvv['orderInfo']['customerId']??'';//客户账号
// $session = $request->get('session_token');//获取操作人信息
$session['admin_groupnew'] = 7;
$session['admin_acc'] = '系统录入';
$session['id'] = 1133;
$session['company_id'] = $company_id;
$return = OrderaddService::addOrder($orders[$kkk], $session, $ip);
CommonService::addLog('添加定单', json_encode($return), $vvv['orderInfo']['salesChannelOrderId'], 'jdAPI_addOrder');
if ($return['ErrorCode'] == 1 && $company_id!=14) {
$url = "http://116.196.75.172/index.php/SaasApiGetOrder/updatestatus?orderId=" . $vvv['orderInfo']['salesChannelOrderId'] . "&storeId=" . $vvv['orderInfo']['warehouseId'];
$urls = $url."&authKey=".$vs['auth_key']."&access_token=".$vs['access_token']."&app_key=".$vs['app_key']."&app_secret=".$vs['app_secret'];
$ck = $this->http_get($urls);
CommonService::addLog('订单出库', $ck, $vvv['orderInfo']['salesChannelOrderId'], 'jdAPI_addOrderck');
}
// dump($return);
unset($orderMsgData);
unset($orders[$kkk]);
if (in_array($vvv['orderInfo']['salesChannelOrderId'], array_column($arr, 'order_id'))) {
unset($arr[$kkk]);
// echo 2;echo '---'.$v['orderId'].'---';
}
// $arr[$kkk]['salesChannelOrderId'] = $v['orderId'];
//
$arr[$kkk]['order_id'] = $vvv['orderInfo']['salesChannelOrderId'];
$arr[$kkk]['admin_acc'] = '系统';
$arr[$kkk]['pt_id'] = $pt_id;
$arr[$kkk]['pay_type'] = '在线支付';
$arr[$kkk]['order_seller_price'] = $v['skuAmount'];
$arr[$kkk]['freight_price'] = $v['transactionPrice'] ?? $vvv['orderInfo']['orderTotalAmount'];
$arr[$kkk]['order_state'] = 'WAIT_SELLER_STOCK_OUT';
$arr[$kkk]['invoice_info'] = '不需要开具发票';
$arr[$kkk]['order_remark'] = $vvv['orderInfo']['promiseMsg'];
$arr[$kkk]['order_start_time'] = date('Y-m-d H:i:s', $v['createTime'] / 1000);
$arr[$kkk]['fullname'] = $vvv['orderShip']['consignee'];
$arr[$kkk]['mobile'] = $vvv['orderShip']['consigneeMobile'];
$arr[$kkk]['telephone'] = $vvv['orderShip']['consigneePhone'];//
$arr[$kkk]['province'] = $vvv['orderShip']['addressLevel1Name'];
$arr[$kkk]['city'] = $vvv['orderShip']['addressLevel2Name'];
$arr[$kkk]['county'] = $vvv['orderShip']['addressLevel3Name'];
$arr[$kkk]['full_address'] = $vvv['orderShip']['deliveryAddress'];
$arr[$kkk]['order_pay'] = $v['skuAmount'];
$arr[$kkk]['is_show'] = 1;
$arr[$kkk]['parent_orderid'] = 0;
DB::table('jd_proprietary')->insert($arr[$kkk]);
// dd($arr[$kkk]);
unset($arr[$kkk]);
} else {
CommonService::addLog('单号已存在', json_encode($vvv), $vvv['orderInfo']['salesChannelOrderId'], 'jdAPI_addOrder');
}
}
}
}
echo "succese";
}
}
}
}
} }
...@@ -1834,4 +1834,19 @@ class CommonService extends Service{ ...@@ -1834,4 +1834,19 @@ class CommonService extends Service{
$resp = file_get_contents($url, false, stream_context_create($arrContextOptions)); $resp = file_get_contents($url, false, stream_context_create($arrContextOptions));
return $resp; return $resp;
} }
public static function https_request($url, $data = null)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
} }
...@@ -2099,7 +2099,7 @@ class OrderService extends Service ...@@ -2099,7 +2099,7 @@ class OrderService extends Service
* @noinspection DuplicatedCode * @noinspection DuplicatedCode
*/ */
public static function lockOrder ( $input , $session , $ip ){ public static function lockOrder ( $input , $session , $ip ){
$order = OrderService::getOrderBy('sys_num', $input['sys_num'],['ser_id', 'order_num', 'order_status','store_type','create_time','new_customer_id','category','p_id']); $order = OrderService::getOrderBy('sys_num', $input['sys_num'],['ser_id', 'order_num', 'order_status','store_type','create_time','new_customer_id','category','p_id','company_id']);
foreach($order as $k => $v){ foreach($order as $k => $v){
$input[$k] = $v; $input[$k] = $v;
} }
...@@ -2415,7 +2415,7 @@ class OrderService extends Service ...@@ -2415,7 +2415,7 @@ class OrderService extends Service
}else{ }else{
$allprice = $input['allprice'];//申请金额 $allprice = $input['allprice'];//申请金额
} }
$poss['company_id'] = $session['company_id']; $poss['company_id'] = $input['company_id']??$session['company_id'];
$refund = RefundService::createRefund($poss); $refund = RefundService::createRefund($poss);
if(!$refund){ if(!$refund){
return ['Data' => '','ErrorMessage'=>'操作失败rf','ErrorCode'=>ErrorInc::MYSQL_FAILED]; return ['Data' => '','ErrorMessage'=>'操作失败rf','ErrorCode'=>ErrorInc::MYSQL_FAILED];
...@@ -2980,10 +2980,10 @@ class OrderService extends Service ...@@ -2980,10 +2980,10 @@ class OrderService extends Service
$BaseController = new BaseController(); $BaseController = new BaseController();
$res = $BaseController->http_get($urls); $res = $BaseController->http_get($urls);
$data = json_decode($res, true); $data = json_decode($res, true);
$result = $data['jingdong_omnic_order_getorderlist_responce']['result']; $result = $data['jingdong_omnic_order_query_orderList_responce']['result'];
$result = json_decode($result, true); $result = json_decode($result, true);
CommonService::addLog('获取取消订单', $urls.'---'.$res, $pt_id, 'orderService-getOrderCancelByJd'); CommonService::addLog('获取取消订单', $urls.'---'.$res, $pt_id, 'orderService-getOrderCancelByJd');
if ($result['success'] == true) { if (isset($result['success'])&&$result['success'] == true) {
$order_data = $result['data']; $order_data = $result['data'];
if (!empty($order_data)) { if (!empty($order_data)) {
$order_data = $order_data['data']; $order_data = $order_data['data'];
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论