Commit 3e890db6 authored by christ's avatar christ

ccw:master_dev

parent bf0edb8e
...@@ -1001,9 +1001,10 @@ class RefundServiceModel extends \Business\AbstractModel ...@@ -1001,9 +1001,10 @@ class RefundServiceModel extends \Business\AbstractModel
// $shippingTypes = ArrayConst::refundShippingType[$orderInfo['shippingType']]; // $shippingTypes = ArrayConst::refundShippingType[$orderInfo['shippingType']];
//获得订单商品 //获得订单商品
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(); $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 = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsByOrderIds'), array($orderInfo['orderId'], $this->orderGoodsField), \Our\ApiConst::oneDaySecond);
$orderGoodses = $orderGoodsDao->convertOrderGoods($orderGoodses, 'goodsId'); $orderGoodses = $orderGoodsDao->convertOrderGoods($orderGoodses, 'goodsId');
$allOrderGoods=$orderGoodses; $allOrderGoods=$orderGoodses;
$goodsIds = $orderGoodsDao->getRefundOrderGoodsIds($orderGoodses); $goodsIds = $orderGoodsDao->getRefundOrderGoodsIds($orderGoodses);
$alreadyRefundGoodsIds=$goodsIds; $alreadyRefundGoodsIds=$goodsIds;
// $this->store=$storeDao->get($this->order['storeId']); // $this->store=$storeDao->get($this->order['storeId']);
...@@ -1013,19 +1014,20 @@ class RefundServiceModel extends \Business\AbstractModel ...@@ -1013,19 +1014,20 @@ class RefundServiceModel extends \Business\AbstractModel
$orderGoods = $orderGoodses[$goodsId]; $orderGoods = $orderGoodses[$goodsId];
} }
if (!empty($orderGoods)) { if (!empty($orderGoods)) {
array_push($goodsIds, $goodsId); array_push($goodsIds, (int)$goodsId);
}else{ }else{
ErrorModel::throwException(CodeConfigModel::notExistOrderGoods); ErrorModel::throwException(CodeConfigModel::notExistOrderGoods);
} }
$shippingFee = ApiConst::zero; $shippingFee = ApiConst::zero;
$allReadyGoodsCount=count($goodsIds); $allReadyGoodsCount=count($goodsIds);
$allGoodsCount=count($orderGoodses); $allGoodsCount=count($orderGoodses);
// $shippingFee = $storeDao->isFee($orderInfo['storeId'], $orderInfo['shippingType'], $orderInfo['orderState']) ? $orderInfo['shippingFee'] : ApiConst::zero; $shippingFee = $storeDao->isFee($orderInfo['storeId'], $orderInfo['shippingType'], $orderInfo['orderState']) ? $orderInfo['shippingFee'] : ApiConst::zero;
if($allReadyGoodsCount==ApiConst::one){ // if($allReadyGoodsCount==ApiConst::one){
$shippingFee = $storeDao->isFee($orderInfo['storeId'], $orderInfo['shippingType'], $orderInfo['orderState']) ? $orderInfo['shippingFee'] : ApiConst::zero; // $shippingFee = $storeDao->isFee($orderInfo['storeId'], $orderInfo['shippingType'], $orderInfo['orderState']) ? $orderInfo['shippingFee'] : ApiConst::zero;
}else{ // }else{
$shippingFee == ApiConst::zero; // $shippingFee == ApiConst::zero;
} // }
// if (count($orderGoods) == ApiConst::one) { // if (count($orderGoods) == ApiConst::one) {
// $shippingFee = $storeDao->isFee($orderInfo['storeId'], $orderInfo['shippingType'], $orderInfo['orderState']) ? $orderInfo['shippingFee'] : ApiConst::zero; // $shippingFee = $storeDao->isFee($orderInfo['storeId'], $orderInfo['shippingType'], $orderInfo['orderState']) ? $orderInfo['shippingFee'] : ApiConst::zero;
// } else { // } else {
...@@ -1055,7 +1057,6 @@ class RefundServiceModel extends \Business\AbstractModel ...@@ -1055,7 +1057,6 @@ class RefundServiceModel extends \Business\AbstractModel
if ($orderInfo['paymentTime']) { if ($orderInfo['paymentTime']) {
$orderConfirmUtil = \Order\OrderConfirmUtil::getInstance(); $orderConfirmUtil = \Order\OrderConfirmUtil::getInstance();
if ($orderInfo['couponId']) { if ($orderInfo['couponId']) {
if ($refundCondition) { if ($refundCondition) {
$refundCondition['storeCarts']['storeCarts'] = $cartDao->refundGoodsRemove($refundCondition['storeCarts']['storeCarts'], $goodsIds); $refundCondition['storeCarts']['storeCarts'] = $cartDao->refundGoodsRemove($refundCondition['storeCarts']['storeCarts'], $goodsIds);
...@@ -1070,45 +1071,33 @@ class RefundServiceModel extends \Business\AbstractModel ...@@ -1070,45 +1071,33 @@ class RefundServiceModel extends \Business\AbstractModel
// if(!$alreadyRefundGoodsIds){ // if(!$alreadyRefundGoodsIds){
// $refundAmount=$refundAmount-$discountAmount; // $refundAmount=$refundAmount-$discountAmount;
// } // }
if($shippingFee){
$refundAmount=$refundAmount-$orderInfo['shippingFee'];
}
} else { } else {
$refundAmount = $orderGoods['goodsPrice']*$orderGoods['goodsNum']; $refundAmount = $orderGoods['goodsPrice']*$orderGoods['goodsNum'];
// if(!$alreadyRefundGoodsIds){ if($allReadyGoodsCount==ApiConst::one){
// $refundAmount=$refundAmount-$discountAmount;
// }
}
if($allReadyGoodsCount==ApiConst::one){
if($orderInfo['couponId']){
if($shippingFee){
$refundAmount=$refundAmount-$orderInfo['shippingFee'];
}
}else{
$refundAmount=$refundAmount+$orderInfo['shippingFee']; $refundAmount=$refundAmount+$orderInfo['shippingFee'];
if($shippingFee){ if($shippingFee){
$refundAmount=$refundAmount-$orderInfo['shippingFee']; $refundAmount=$refundAmount-$orderInfo['shippingFee'];
} }
} }
// if($shippingFee && ($orderInfo['shippingType']==ApiConst::bySeller)){ //修改后的优惠金额按比例退回
// $refundAmount=$refundAmount-$orderInfo['shippingFee']; $discountAmount=$orderInfo['originAmount']- $orderInfo['orderAmount'];
// } $mustReduceAmount=ApiConst::zero;
}else{ if($discountAmount){
if($orderInfo['couponId']){ $orderGoodsConvertes=array();
if($shippingFee){ array_push($orderGoodsConvertes,$orderGoodsConvert);
$refundAmount=$refundAmount-$orderInfo['shippingFee']; $mustReduceAmount=$orderGoodsDao->getMustReduceAmount($allOrderGoods,$discountAmount,$orderGoodsConvertes);
}
} }
}
//修改后的优惠金额按比例退回
$discountAmount=$orderInfo['originAmount']- $orderInfo['orderAmount'];
$mustReduceAmount=ApiConst::zero;
if($discountAmount){
$mustReduceAmount=$orderGoodsDao->getMustReduceAmount($allOrderGoods,$discountAmount,$orderGoodsConvert);
}
if(!$orderInfo['couponId']){
$refundAmount=$refundAmount-$mustReduceAmount; $refundAmount=$refundAmount-$mustReduceAmount;
// if(!$alreadyRefundGoodsIds){
// $refundAmount=$refundAmount-$discountAmount;
// }
} }
//配送订单配送费按比例收取 //配送订单配送费按比例收取
// if($orderInfo['shippingType']==ApiConst::bySeller){ // if($orderInfo['shippingType']==ApiConst::bySeller){
// $mustSheepingFee=ApiConst::zero; // $mustSheepingFee=ApiConst::zero;
......
...@@ -271,18 +271,23 @@ class CartModel extends \DAO\AbstractModel{ ...@@ -271,18 +271,23 @@ class CartModel extends \DAO\AbstractModel{
return false; return false;
} }
public function refundGoodsRemove($storeCarts,$goodsIds){ public function refundGoodsRemove($storeCarts,$goodsIds){
for($i=0;$i<count($storeCarts);$i++){ $newStoreCarts= array();
if(is_array($goodsIds)){
if(in_array($storeCarts[$i]['goodsId'],$goodsIds)){ foreach($storeCarts as $val){
unset($storeCarts[$i]); if(is_array($goodsIds)){
} if(!in_array($val['goodsId'],$goodsIds)){
}else{ array_push($newStoreCarts,$val);
if($storeCarts[$i]['goodsId']==$goodsIds){ // unset($storeCarts[$i]);
unset($storeCarts[$i]); }
}else{
if($val['goodsId']!=$goodsIds){
array_push($newStoreCarts,$val);
}
} }
} }
} return $newStoreCarts;
return $storeCarts;
} }
public function insertAllOrUpdate($datas){ public function insertAllOrUpdate($datas){
......
...@@ -45,7 +45,7 @@ class OrderModel extends \DAO\AbstractModel ...@@ -45,7 +45,7 @@ class OrderModel extends \DAO\AbstractModel
public function getOrderDetailField() public function getOrderDetailField()
{ {
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'; 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,origin_refund_amount as originRefundAmount';
} }
public function getOrderShippingField() public function getOrderShippingField()
......
...@@ -179,12 +179,17 @@ class OrderGoodsModel extends \DAO\AbstractModel ...@@ -179,12 +179,17 @@ class OrderGoodsModel extends \DAO\AbstractModel
{ {
$newOrderGoods = array(); $newOrderGoods = array();
$orderGoods = array_values($orderGoods); $orderGoods = array_values($orderGoods);
for ($i = ApiConst::zero; $i < count($orderGoods); $i++) { foreach($orderGoods as $orderGood){
if ($orderGoods[$i]['refundId'] != ApiConst::zero) { if($orderGood['refundId']!=ApiConst::zero){
array_push($newOrderGoods, $orderGoods); array_push($newOrderGoods, $orderGood);
// unset($orderGoods[$i]);
} }
} }
// for ($i = ApiConst::zero; $i < count($orderGoods); $i++) {
// if ($orderGoods[$i]['refundId'] != ApiConst::zero) {
// array_push($newOrderGoods, $orderGoods);
// // unset($orderGoods[$i]);
// }
// }
$goodsIds = array_column($newOrderGoods, 'goodsId'); $goodsIds = array_column($newOrderGoods, 'goodsId');
return $goodsIds; return $goodsIds;
} }
...@@ -241,7 +246,11 @@ class OrderGoodsModel extends \DAO\AbstractModel ...@@ -241,7 +246,11 @@ class OrderGoodsModel extends \DAO\AbstractModel
// $allGoodsPrice = array_column($orderGoodses, 'goodsPrice'); // $allGoodsPrice = array_column($orderGoodses, 'goodsPrice');
// $allGoodsPrice=array_sum($allGoodsPrice); // $allGoodsPrice=array_sum($allGoodsPrice);
// $allMoney = $allNumbers * $allGoodsPrice; // $allMoney = $allNumbers * $allGoodsPrice;
$thisOrderGoodsAmount = $convertOrderGoods['goodsNum'] * $convertOrderGoods['goodsPrice']; $thisOrderGoodsAmount=ApiConst::zero;
foreach($convertOrderGoods as $convertOrderGood){
$thisOrderGoodsAmount += $convertOrderGood['goodsNum'] * $convertOrderGood['goodsPrice'];
}
$reduceAmount=($discountAmount*$thisOrderGoodsAmount)/($allMoney); $reduceAmount=($discountAmount*$thisOrderGoodsAmount)/($allMoney);
return round($reduceAmount); return round($reduceAmount);
......
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