Commit 3e890db6 authored by christ's avatar christ

ccw:master_dev

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