Browse Source

订单退款--添加处理特价商品

master
liangyuyan 6 years ago
parent
commit
b532ae133c
  1. 11
      app/Controller/NotifyPayRefundController.php
  2. 2
      app/Service/CouponService.php
  3. 12
      app/Service/OrderService.php
  4. 11
      app/Service/OrderServiceInterface.php

11
app/Controller/NotifyPayRefundController.php

@ -69,13 +69,18 @@ class NotifyPayRefundController extends BaseController
}
/* --- 退款成功 --- */
// 退款返还优惠券
$this->couponService->orderRefundCoupon($message['out_trade_no']);
// 添加用户的流水
$orderMain = OrderMain::select('id','global_order_id','money','user_id')
->where('global_order_id',$message['out_trade_no'])
->where('state',OrderMain::ORDER_STATE_REFUNDED)
->first();
// 退款返还优惠券
$this->couponService->orderRefundCoupon($message['out_trade_no']);
// 删除特价商品缓存
$this->orderService->clearTodayGoodPurchase($orderMain->user_id,1);
// 添加用户的流水
if(!empty($orderMain)){
$this->financialService->userByOLOrderRefund($orderMain->user_id, $orderMain->global_order_id, $orderMain->money);
}

2
app/Service/CouponService.php

@ -262,7 +262,7 @@ class CouponService implements CouponServiceInterface
* @param $couponId
* @return bool
*/
function clearTodayCouponUsed($userId, $couponId)
public function clearTodayCouponUsed($userId, $couponId)
{
$redis = ApplicationContext::getContainer()->get(Redis::class);

12
app/Service/OrderService.php

@ -22,6 +22,7 @@ use Hyperf\Di\Annotation\Inject;
use App\Service\WxRefundServiceInterface;
use App\Service\UserServiceInterface;
use App\Model\Users;
use App\Constants\SsdbKeysPrefix;
class OrderService implements OrderServiceInterface
{
@ -779,6 +780,8 @@ class OrderService implements OrderServiceInterface
// 返还优惠券
$this->couponService->orderRefundCoupon($global_order_id);
// 删除特价商品缓存
$this->orderService->clearTodayGoodPurchase($orderMain->user_id,1);
// 添加用户流水
$this->financialService->userByOLOrderRefund($orderMain->user_id, $orderMain->global_order_id, $orderMain->money);
}
@ -836,4 +839,13 @@ class OrderService implements OrderServiceInterface
return false;
}
}
/**
* 删除特价商品缓存
*/
public function clearTodayGoodPurchase($userId, $goodId)
{
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
return $ssdb->exec('hdel', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$userId, $goodId);
}
}

11
app/Service/OrderServiceInterface.php

@ -61,4 +61,15 @@ interface OrderServiceInterface
* @return mixed
*/
public function onlineRefund($global_order_id);
/**
* 订单退款失败
* 回退订单状态
*/
public function onlineRefundFail($global_order_id);
/**
* 删除特价商品缓存
*/
public function clearTodayGoodPurchase($userId, $goodId);
}
Loading…
Cancel
Save