Commit e5d710a7 authored by wwccw0591's avatar wwccw0591

pc

parent f71fd22c
......@@ -54,7 +54,7 @@ class OrderController extends \Our\Controller_AbstractApi {
public function getExpressAction(){
$orderService=\Business\Order\OrderServiceModel::getInstance();
$orderService->getExpressInfo($this->req[\Our\NameConst::data]['orderId']);
// $expreddInfo= $orderService->getExpressInfo($this->req[\Our\NameConst::data]['orderId']);
$expreddInfo=\Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(),array(&$orderService, 'getExpressInfo'),array($this->req[\Our\NameConst::data]['orderId']),\Our\ApiConst::oneHour);;
$this->success($expreddInfo,\Our\DescribeConst::getExpreeSuccess);
}
......
......@@ -19,6 +19,8 @@ class ApiConst
const halfDaySecond = 43200;
//一个小时
const oneHour = 3600;
const fiveMinutes=180;
//10分钟秒数
const tenMinSecond = 600;
//7天秒数
......@@ -55,6 +57,8 @@ class ApiConst
const cannotSendMsg=-1;
const canSendMsg=1;
const getExpressSuccess=0;
const favTimeAsc = 1;
const favTimeDesc = 2;
const orderTotalAsc = 3;
......
......@@ -494,6 +494,32 @@ class Common
curl_close($curl);
return $r;
}
public static function aliyunExpressApi($expressNo,$expressType){
$host = SecretKeys::expressUrl;
$path = SecretKeys::expressPath;
$method = "GET";
$appcode = SecretKeys::expressAppCode;
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys=self::format("no={0}&type={1}",$expressNo,$expressType);
$bodys = "";
$url = $host . $path . "?" . $querys;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
if (ApiConst::one == strpos("$".$host, "https://"))
{
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$res=curl_exec($curl);
return json_decode($res,true);
}
/**
* 价格格式化
*
......
......@@ -72,6 +72,8 @@ class NameConst {
const lat = 'lat';
const lng = 'lng';
const address = 'address';
//物流连表
const expressList='expressList';
const wechatAuthUrl = 'https://api.weixin.qq.com/sns/jscode2session?';
......
......@@ -9,6 +9,9 @@ class RedisHelper
{
public static $conf;
public static $redis;
/**
* 对根据参数,对函数的结果进行缓存,一般用于数据库 API 缓存
*
......@@ -184,7 +187,47 @@ class RedisHelper
$memberDao=\DAO\MemberModel::getInstance(DbNameConst::masterDBConnectName);
return $memberDao->fromOrderStateToOrderState($memberId,$fromState,$toState);
}
/**
* 删除缓存
*
* @param explessList 快递
* @param
* @param array $args 函数参数数组
* @param number $ttl 过期时间,单位:秒
* @param array $options 额外参数
* @throws Exception
* @return mixed 返回执行 $function 返回的结果
*/
public static function rpush($expressName,$data)
{
if(empty(self::$conf)){
self::$conf=\Yaf\Registry::get('config')->get('redis.database.params');
}
if(empty(self::$redis)){
$redis=new \Redis();
$redis->connect(self::$conf['host'], self::$conf['port']);
if(!empty(self::$conf['password'])){
$redis->auth(self::$conf['password']);
}
}
$redis->rPush($expressName,serialize($data));
}
public static function lpop($expressName){
if(empty(self::$conf)){
self::$conf=\Yaf\Registry::get('config')->get('redis.database.params');
}
if(empty(self::$redis)){
$redis=new \Redis();
$redis->connect(self::$conf['host'], self::$conf['port']);
if(!empty(self::$conf['password'])){
$redis->auth(self::$conf['password']);
}
}
if($getData = $redis->lpop($expressName)){
return unserialize($getData);
}else{
return false;
}
}
}
......@@ -40,6 +40,12 @@ class SecretKeys {
const wxAppId = 'wxAppId';
const wxAppSecret = 'wxAppSecret';
const expressAppKey="25073044";
const expressAppSecret='69f78ac0ee9026a8a3d9ce9a04f95d8e';
const expressAppCode='3301e8fc56954117a208c1aacc352532';
const expressUrl='https://kdwlcxf.market.alicloudapi.com';
const expressPath='/kdwlcx';
}
......
File mode changed from 100755 to 100644
......@@ -75,6 +75,8 @@ class WxPay extends \Payment\TencentPay
$this->parameters['total_fee'] = $total_fee;
$this->parameters['refund_fee'] = $refund_fee;
}
$this->parameters['total_fee'] = $total_fee;
$this->parameters['refund_fee'] =$refund_fee;
$this->parameters['out_refund_no'] = $param['refundOrderNo'];
$this->parameters['out_trade_no'] = $param['outTradeNo'];
$this->parameters['op_user_id'] = $this->mch_id;
......
......@@ -16,6 +16,7 @@ use Our\ImageConst;
use Our\NameConst;
use Our\PageConst;
use Our\Push;
use Our\RedisHelper;
/**
* 店铺service
......@@ -371,7 +372,23 @@ class OrderServiceModel extends \Business\AbstractModel
} else {
$shippingExpressInfo = new \stdClass();
}
$order = $orderDao->findByOrderId($orderId, $this->getOrderExpressField());
if(empty($order)){
return new \stdClass();
}
$eCode=$shippingExpressInfo['eCode'];
$shippingCode=$order['shippingCode'];
$order['shippingHtml']=$order['shippingHtml'] ? unserialize($order['shippingHtml']) : array();;
$expressResult=Common::aliyunExpressApi($shippingCode,$eCode);
if($order['shippingOver']!=ApiConst::one){
if($expressResult['status']==ApiConst::getExpressSuccess){
$order['shippingHtml']=$expressResult['result']['list'];
$listData['orderId']=$order['orderId'];
$listData['expressInfo']=$expressResult['result'];
RedisHelper::rpush(NameConst::expressList,$listData);
}
}
$orderGoods = $orderGoods->getOneByOrderId($orderId, $this->orderGoodsField);
if (!empty($order) && !empty($orderGoods)) {
$return['shippingCode'] = $order['shippingCode'];
......@@ -382,7 +399,7 @@ class OrderServiceModel extends \Business\AbstractModel
$return['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($orderGoods['goodsImage'], ArrayConst::goodsImageExt[ApiConst::goodsSmallSize]);
$return['goodsAttr'] = $goodsDao->getFormatGoodsAttr($orderGoods['goodsSpec']);
$return['orderPrice'] = $order['orderAmount'];
$return['expressInfo'] = $order['shippingHtml'] ? unserialize($order['shippingHtml']) : array();
$return['expressInfo'] = $order['shippingHtml'];
$return['shippingStatus'] = $order['shippingStatus'];
$return['sendTime'] = $order['sendTime'];
$return['rechedTime'] = $order['shippingSign'];
......@@ -669,45 +686,27 @@ class OrderServiceModel extends \Business\AbstractModel
{
$orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::masterDBConnectName);
$orderCommonDao = \DAO\Order\OrderCommonModel::getInstance(DbNameConst::salveDBConnectName);
$where['order_state'] = ApiConst::orderStateWaitRecieve;
$where['shipping_type'] = ApiConst::express;
$where['shipping_status'] = array('lt', ApiConst::shippingStatusArrive);
$orders = $orderDao->getListByCon($where, $orderDao->getOrderShippingField());
$orderIds = array_column($orders, 'orderId');
$shippingExpressIds = $orderCommonDao->getAllByOrderIds($orderIds, $orderCommonDao->getShippingFields(), 'orderId');
$expesses = array_column(ExpressConst::expresses, 'eCode', 'id');
foreach ($orders as $order) {
$url = Common::format(ExpressConst::expressUrl . "?appkey={0}", ExpressConst::expressKey);
$type = $expesses[$shippingExpressIds[$order['orderId']]];
$number = $order['shippingCode'];
$post = array('type' => $type,
'number' => $number
);
$result = Common::sendurl($url, '', $post, 'post');
$jsonarr = json_decode($result, true);
if ($jsonarr['status'] != 0) {
continue;
while($result=RedisHelper::lpop(NameConst::expressList)){
if($result){
$expressInfo=$result['expressInfo'];
}
$result = $jsonarr['result'];
//if($result['issign'] == 1) echo '<li>已签收</li>';
//else echo '<li>未签收'.'</li>';
$data = array();
//deliverystatus int 物流状态 1在途中 2派件中 3已签收 4派送失败(拒签等)
if ($result['deliverystatus'] == 3) {
if ($expressInfo['deliverystatus'] == 3) {
$data['shipping_over'] = 1;
}
if ($result['list']) {
$data['shipping_sign'] = strtotime($result['list'][0]['time']);//签收时间
$data['shipping_html'] = serialize($result['list']);
$data['shipping_status'] = $result['deliverystatus'];
}//$output;
if ($expressInfo['list']) {
$data['shipping_sign'] = strtotime($expressInfo['list'][0]['time']);//签收时间
$data['shipping_html'] = serialize($expressInfo['list']);
$data['shipping_status'] = $expressInfo['deliverystatus'];
}
//$output;
//更新订单物流
$result = $orderDao->update(array('order_id' => $order['orderId']), $data);
$result = $orderDao->update(array('order_id' => $result['orderId']), $data);
if ($result !== false) {
echo '物流信息更新成功订单号:' . $order['orderSn'] . "\r\n";
echo '物流信息更新成功订单号:' . $result['orderId'] . "\r\n";
}
}
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment