Commit 90bda454 authored by zhz's avatar zhz

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into master_dev

parents 616f56ac a9be1560
......@@ -20,7 +20,7 @@ class Common
const endpointPre=SecretKeys::ossEndpointPre;
const buketPre=SecretKeys::ossBucket;
const buketPre=SecretKeys::ossBucketPre;
public static function getOssClientOnline(){
try {
......
......@@ -1133,7 +1133,9 @@ class OrderConfirmUtil {
return array('flag'=>\Our\ApiConst::zero,'errorCode'=>$errorCode,'data'=>$data);
}
$oldOrderPay = $orderPayModel->find(array('pay_sn'=>$paySn));
if($oldOrderPay['api_pay_state']==\Our\ApiConst::one){
\Our\Log::getInstance()->write(json_encode($oldOrderPay),'/data/log/apptest');
if($oldOrderPay['api_pay_state']==\Our\ApiConst::one){
\Our\Log::getInstance()->write('testaldeary','/data/log/apptest');
return array('flag'=>\Our\ApiConst::one,'errorCode'=>$errorCode);
}
$resultOrderPay = $orderPayModel->update(array('api_pay_state'=>\Our\ApiConst::one,'pay_type'=>$data['pay_type']),array('pay_sn'=>$paySn));
......
......@@ -82,6 +82,7 @@ class TencentPay {
$this->parameters['trade_type']= $this->tradeType;
//$this->parameters['openid']=$_SESSION['openid'];
//print_r($this->parameters);exit;
\Our\Log::getInstance()->write(json_encode($this->parameters),'/data/log/apptest');
$prepay_id = $this->getPrepayId();
$this->setPrepayId($prepay_id);
}
......
......@@ -12,7 +12,8 @@ class WxLitePay extends \Payment\TencentPay{
public function __construct()
{
$this->appid = \Our\PayConst::wxLiteAppId;
$this->notify_url = \Our\Common::getBaseUrl().\Our\PayConst::wxLiteNotifyUrl;
//$this->notify_url = \Our\Common::getBaseUrl().\Our\PayConst::wxLiteNotifyUrl;
$this->notify_url = \Our\NameConst::httpPrefix. $_SERVER['SERVER_NAME'] .\Our\PayConst::wxLiteNotifyUrl;
$this->mch_id = \Our\PayConst::wxPayMchId;
$this->key = \Our\PayConst::wxSPayKey;
$this->sslcert_path = \Our\PayConst::wxSslcertPath;
......
......@@ -41,6 +41,7 @@ class PaymentServiceModel extends \Business\AbstractModel{
* app微信支付回调
*/
public function updateOrderToPayed($channel = \Our\NameConst::wxAppChannel){
\Our\Log::getInstance()->write(microtime(),'/data/log/apptest');
if($channel == \Our\NameConst::wxLiteChannel){
$wxpay = \Payment\WxLitePay::getInstance();
$param['pay_type'] = \Our\ApiConst::wxLitePayType;
......@@ -57,6 +58,9 @@ class PaymentServiceModel extends \Business\AbstractModel{
$param['paySn'] = $callbackInfo['out_trade_no'];
$orderConfirmUtil = \Order\OrderConfirmUtil::getInstance();
$return = $orderConfirmUtil->updateOrderToPayed($param);
\Our\Log::getInstance()->write(json_encode($return),'/data/log/apptest');
\Our\Log::getInstance()->write(microtime(),'/data/log/apptest');
\Our\Log::getInstance()->write(json_encode($callbackInfo),'/data/log/apptest');
if($return['flag']) {
echo $callbackInfo['returnXml'];
die;
......
......@@ -14,6 +14,7 @@ use Our\ImageConst;
use Our\ImageUtil;
use Our\NameConst;
use Our\OrderConst;
use Zend\Validator\File\Count;
/**
* 店铺service
......@@ -441,8 +442,9 @@ class RefundServiceModel extends \Business\AbstractModel
//获取订单
$order_id = $refund['order_id'];
$order_info = $orderDao->find( array('order_id'=>$order_id));
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
$orderData['refund_amount']=$refundAmount;
$orderDao->updateByOrderId($orderData,$order_id);
$refund_array = array();
$refund_array['seller_time'] = time();
$refund_array['seller_state'] = $seller_state;//卖家处理状态:1为待审核,2为同意,3为不同意
......@@ -991,7 +993,9 @@ class RefundServiceModel extends \Business\AbstractModel
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance();
$orderGoodses = \Our\RedisHelper::cachedFunction(\Redis\Db5\RefundReasonRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsByOrderIds'), array($orderInfo['orderId'], $this->orderGoodsField), \Our\ApiConst::oneDaySecond);
$orderGoodses = $orderGoodsDao->convertOrderGoods($orderGoodses, 'goodsId');
$allOrderGoods=$orderGoodses;
$goodsIds = $orderGoodsDao->getRefundOrderGoodsIds($orderGoodses);
$alreadyRefundGoodsIds=$goodsIds;
// $this->store=$storeDao->get($this->order['storeId']);
// $this->store=Common::convertUnderline($this->store[0]);
$this->store = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$storeDao, 'getInfoById'), array($orderInfo['storeId'], $storeDao->detailField), \Our\ApiConst::sevenDaySecond,array($orderInfo['storeId']));
......@@ -1004,11 +1008,18 @@ class RefundServiceModel extends \Business\AbstractModel
ErrorModel::throwException(CodeConfigModel::notExistOrderGoods);
}
$shippingFee = ApiConst::zero;
if (count($orderGoods) == ApiConst::one) {
$shippingFee = $storeDao->isFee($orderInfo['storeId'], $orderInfo['shippingType'], $orderInfo['order_state']) ? $orderInfo['shippingFee'] : ApiConst::zero;
} else {
$allReadyGoodsCount=count($goodsIds);
$allGoodsCount=count($orderGoodses);
if($allReadyGoodsCount==$allGoodsCount){
$shippingFee = $storeDao->isFee($orderInfo['storeId'], $orderInfo['shippingType'], $orderInfo['orderState']) ? $orderInfo['shippingFee'] : ApiConst::zero;
}else{
$shippingFee == ApiConst::zero;
}
// if (count($orderGoods) == ApiConst::one) {
// $shippingFee = $storeDao->isFee($orderInfo['storeId'], $orderInfo['shippingType'], $orderInfo['orderState']) ? $orderInfo['shippingFee'] : ApiConst::zero;
// } else {
// $shippingFee == ApiConst::zero;
// }
$orderGoodsConvert = $orderGoodsDao->getRefundOrderGoods($orderGoods);
$returnData = array(
......@@ -1031,6 +1042,12 @@ class RefundServiceModel extends \Business\AbstractModel
// if($orderInfo['shippingType']==ApiConst::bySelf){
$returnData['needShippingFee']=ApiConst::zero;
// }
//修改后的优惠金额
$discountAmount=$orderInfo['originAmount']- $orderInfo['orderAmount'];
$mustReduceAmount=ApiConst::zero;
if($discountAmount){
$mustReduceAmount=$orderGoodsDao->getMustReduceAmount($allOrderGoods,$discountAmount,$orderGoodsConvert);
}
if ($orderInfo['paymentTime']) {
$orderConfirmUtil = \Order\OrderConfirmUtil::getInstance();
......@@ -1039,20 +1056,38 @@ class RefundServiceModel extends \Business\AbstractModel
$refundCondition['storeCarts']['storeCarts'] = $cartDao->refundGoodsRemove($refundCondition['storeCarts']['storeCarts'], $goodsIds);
if (!empty($refundCondition['storeCarts']['storeCarts'])) {
$newTotalPrice = $orderConfirmUtil->reCalcOrderAmount($refundCondition['coupon'], $refundCondition['storeCarts']['storeCarts']);
$refundAmount = $orderInfo['orderAmount'] - $orderInfo['shippingFee'] - $newTotalPrice;
$refundAmount = $orderInfo['orderAmount'] - $newTotalPrice;
} else {
$refundAmount = $orderInfo['orderAmount'] - $orderInfo['shippingFee'] - ApiConst::zero;;
$refundAmount = $orderInfo['orderAmount'] - ApiConst::zero;;
}
}
} else {
// if(!$alreadyRefundGoodsIds){
// $refundAmount=$refundAmount-$discountAmount;
// }
//$refundAmount = $orderGoods['goodsPrice']*$orderGoods['goodsNum'];
$refundAmount =$orderInfo['orderAmount'];
} else {
$refundAmount = $orderGoods['goodsPrice']*$orderGoods['goodsNum'];
// if(!$alreadyRefundGoodsIds){
// $refundAmount=$refundAmount-$discountAmount;
// }
}
$refundAmount=$refundAmount-$mustReduceAmount;
if($orderInfo['shippingType']==ApiConst::bySeller){
if(!$shippingFee){
$refundAmount=$refundAmount+$orderInfo['shippingFee'];
}
}
$returnData['refundAmount'] = $refundAmount - $orderInfo['refundAmount'] - $returnData['needShippingFee'] + $shippingFee;
$liveMoney=$orderInfo['orderAmount']-$orderInfo['refundAmount'];
if($refundAmount>$liveMoney){
$refundAmount=$liveMoney;
}
// $returnData['refundAmount'] = $refundAmount - $orderInfo['refundAmount'] - $returnData['needShippingFee'] + $shippingFee;
$returnData['refundAmount'] = $refundAmount - $returnData['needShippingFee'];
if((int)$returnData['refundAmount'] <ApiConst::zero){
$returnData['refundAmount']=ApiConst::zero;
}
// if($orderGoods['goodsType']==ApiConst::goodsTypeFour){
// //已经退款过的金额
// $alreadyRefundMoney=$orderGoodsDao->getIsRefundMoney($orderGoodses,$orderGoods['promotionsId']);
......@@ -1108,6 +1143,8 @@ class RefundServiceModel extends \Business\AbstractModel
$orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::masterDBConnectName);
$orderInfo = $orderDao->findByMemberIdAndOrderId($memberId, $refund['orderId'], $this->orderField);
$storeDao=\DAO\StoreModel::getInstance();
$orderDao->setDb(DbNameConst::masterDBConnectName);
$orderDao->db->doTransaction();
if($refund['refundType']==ApiConst::refundTypeGoods){
$refund['refundAmount']-=$orderInfo['needShippingFee'];
}
......@@ -1184,15 +1221,22 @@ class RefundServiceModel extends \Business\AbstractModel
$refundArray['refund_shipping_type']=isset($refund['refundShippingType'])?$refund['refundShippingType']:ApiConst::zero;
$refundArrayUnLine=Common::convertUnderline($refundArray);
$state = $refundReturnDao->addRefundReturn($refundArray,$orderInfo,$orderGoods);
$updateOrderData['refund_amount']= $refundArray['refund_amount'];
$orderDao->deleteOrderCache($memberId,$orderInfo['orderId'],$orderInfo['storeId'],true);
$storeDao->deleteStoreCache($orderInfo['storeId'],$orderInfo['orderId']);
$storeDao->deleteStoreRefundCache($orderInfo['storeId'],$orderInfo['orderId']);
if ($state) {
$orderDao->update(array('order_id'=>$orderInfo['orderId']),$updateOrderData);
$refundStateName=$refundReturnDao->getRefundTextStatus($refundArrayUnLine);
$orderGoodsDao->update(array('rec_id'=>$orderGoods['recId']),array('refund_state_name'=>$refundStateName,'refund_id'=>$state));
$refundReturnDao->deleteRefundCache($memberId);
$storeDao->deleteStoreRefundCache($refundOne['storeId']);
$orderLogDao->addRefundOrderLog($orderInfo['orderId'],$refundArray['refund_type'],DescribeConst::buyer,$orderInfo['buyerName'],$orderInfo['orderState']);
if ($orderInfo['orderState'] == ApiConst::orderStateWaitRecieve) {
$orderDao->editOrderLock($orderInfo['orderId']);
}
$orderDao->db->doCommit();
$push=\Our\Push::getInstance();
$pushData=array('storeId'=>$orderInfo['storeId'],
'type'=>ApiConst::messageRefund,
......@@ -1211,11 +1255,10 @@ class RefundServiceModel extends \Business\AbstractModel
$push->sendTcpMessage();
//\Our\RedisHelper::rpush('client_push',array('storeId'=>$refund['storeId'],'type'=>ApiConst::messageRefundProccessing,'op'=>NameConst::reduce,'num'=>ApiConst::one,'params'=>array('c'=>'shopkeeper','m'=>'getRefundDetail','refundId'=>$refund['refundId'])));
if ($orderInfo['orderState'] == ApiConst::orderStateWaitRecieve) {
$orderDao->editOrderLock($orderInfo['orderId']);
}
return $state;
} else {
$orderDao->db->doRollback();
ErrorModel::throwException(CodeConfigModel::refundRefuseByStore);
}
}
......
......@@ -488,7 +488,11 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
ErrorModel::throwException(CodeConfigModel::emptyStoreId);
}
$diliveryMan = \DAO\Order\DiliverymanModel::getInstance();
return \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$diliveryMan, 'getDeliveryManByStoreId'), array($storeId), \Our\ApiConst::oneHourCache, array($storeId));
$diliveryMans=\Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$diliveryMan, 'getDeliveryManByStoreId'), array($storeId), \Our\ApiConst::oneHourCache, array($storeId));
foreach($diliveryMans as &$dilivery){
$dilivery['memberAvatar']=$memberDao->getMemberAvatar($dilivery['memberId']);
}
return $diliveryMans;
}
public function confirmReceivePayment($memberId,$orderId){
......
......@@ -45,7 +45,7 @@ class OrderModel extends \DAO\AbstractModel
public function getOrderDetailField()
{
return 'order_id as orderId,coupon_id as couponId,refund_amount as refundAmount,order_sn as orderSn,pay_sn as paySn,store_name as storeName,add_time as addTime,store_id as storeId,goods_amount as goodsAmount,shipping_fee as shippingFee,order_amount as orderAmount,shipping_type as shippingType,payment_type as paymentType,order_state as orderState,shipping_fee as shippingFee,refund_state as refundState,order_type as orderType,is_receive_payment as isReceivePayment,payment_time as paymentTime,finnshed_time as finnshedTime,need_shipping_fee as needShippingFee,payment_code as paymentCode,buyer_id as buyerId,buyer_name as buyerName,refund_condition as refundCondition,delay_time as delayTime,gmt_update as gmtUpdate,diliveryman_id as diliverymanId,shipping_arrival_time as shippingArrivalTime,delivery_time as deliveryTime,order_note as orderNote,send_time as sendTime';
return 'order_id as orderId,coupon_id as couponId,refund_amount as refundAmount,origin_amount as originAmount,order_sn as orderSn,pay_sn as paySn,store_name as storeName,add_time as addTime,store_id as storeId,goods_amount as goodsAmount,shipping_fee as shippingFee,order_amount as orderAmount,shipping_type as shippingType,payment_type as paymentType,order_state as orderState,shipping_fee as shippingFee,refund_state as refundState,order_type as orderType,is_receive_payment as isReceivePayment,payment_time as paymentTime,finnshed_time as finnshedTime,need_shipping_fee as needShippingFee,payment_code as paymentCode,buyer_id as buyerId,buyer_name as buyerName,refund_condition as refundCondition,delay_time as delayTime,gmt_update as gmtUpdate,diliveryman_id as diliverymanId,shipping_arrival_time as shippingArrivalTime,delivery_time as deliveryTime,order_note as orderNote,send_time as sendTime';
}
public function getOrderShippingField()
......
This diff is collapsed.
......@@ -208,7 +208,8 @@ class StoreModel extends \DAO\AbstractModel
public function isChargeGet($storeId)
{
$isChargeGet = $this->getInfoById($storeId, 'is_charge_get');
return $isChargeGet > ApiConst::zero ? TRUE : FALSE;
return $isChargeGet['is_charge_get'] > ApiConst::zero ? TRUE : FALSE;
}
//线上支付订单已接单待发货退款是否收取服务费(0:否 1:是)
......
......@@ -303,7 +303,7 @@ class ShopkeeperController extends \Our\Controller_AbstractClient {
ErrorModel::throwException(CodeConfigModel::notExistRefund);
}
$refundService=\Business\Order\RefundServiceModel::getInstance();
$goodsState= intval($this->req['data']['goodsState']);
$goodsState=isset($this->req['data']['goodsState'])?intval($this->req['data']['goodsState']):\Our\ApiConst::goodsStateRecieved;
$res = $refundService->receive($this->storeId, $this->sellerId, $this->sellerName, $refundId, $goodsState);
if($res){
$this->success($res);
......
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