Browse Source

取消订单接口 order_id 改为 global_order_id

master
Lemon 5 years ago
parent
commit
d6990ccbaa
  1. 7
      app/Controller/OrderController.php
  2. 10
      app/Service/CouponService.php
  3. 2
      app/Service/CouponServiceInterface.php
  4. 8
      app/Service/OrderService.php
  5. 2
      app/Service/OrderServiceInterface.php
  6. 2
      app/Service/PurchaseLimitService.php

7
app/Controller/OrderController.php

@ -102,8 +102,11 @@ class OrderController extends BaseController
* 用户取消订单
*/
public function onlineCancel(){
$OrderId = $this->request->input('order_id');
return $this->success($this->orderService->onlineCancel($OrderId));
$orderId = $this->request->input('order_id');
$orderMain = OrderMain::where('id',$orderId)
->select('global_order_id')
->first();
return $this->success($this->orderService->onlineCancel($orderMain->global_order_id));
}
}

10
app/Service/CouponService.php

@ -2,6 +2,7 @@
namespace App\Service;
use App\Model\OrderMain;
use Hyperf\Di\Annotation\Inject;
use Hyperf\DbConnection\Db;
use App\Model\CouponUserRecType;
@ -284,7 +285,11 @@ class CouponService implements CouponServiceInterface
* @param $order_id
* @return bool
*/
public function refundOrderCoupons($order_id){
public function refundOrderCoupons($global_order_id){
$order_main = OrderMain::where('global_order_id',$global_order_id)
->select('id','user_id')
->first();
$order_id = $order_main->id;
$coupon = CouponUserUse::where([
['order_main_id','=',$order_id],
['status','=',CouponUserUse::COUPON_USE_STATE_USED],
@ -312,9 +317,6 @@ class CouponService implements CouponServiceInterface
]);
//删除当日 redis 使用记录缓存
$order_main = OrderMain::where('id',$order_id)
->select('global_order_id','user_id')
->first();
$redis = ApplicationContext::getContainer()->get(Redis::class);
$remRes = $redis->sRem(
'coupon_'.date('Ymd').'_used_'.$order_main->user_id,

2
app/Service/CouponServiceInterface.php

@ -27,7 +27,7 @@ interface CouponServiceInterface
*/
public function getOrderCanUseCoupons($orderAmount, $marketId, $userId, $fields=[], $type=1, $storeTypeIds=[0]);
public function refundOrderCoupons($order_id);
public function refundOrderCoupons($global_order_id);
public function clearTodayCouponUsed($userId, $couponId);
public function orderRefundCoupon($global_order_id);
}

8
app/Service/OrderService.php

@ -729,13 +729,13 @@ class OrderService implements OrderServiceInterface
/**
* @inheritDoc
*/
public function onlineCancel($order_id){
OrderMain::where('id',$order_id)
public function onlineCancel($global_order_id){
OrderMain::where('global_order_id',$global_order_id)
->update(['state' => OrderMain::ORDER_STATE_CANCEL]);
//撤销redis 用券记录
$res = $this->couponService->refundOrderCoupons($order_id);
$res = $this->couponService->refundOrderCoupons($global_order_id);
//撤销特价商品购买记录
$res = $this->purchaseLimitService->delSsdbPurchaseRecord($order_id);
$res = $this->purchaseLimitService->delSsdbPurchaseRecord($global_order_id);
return $res;
}
/**

2
app/Service/OrderServiceInterface.php

@ -53,7 +53,7 @@ interface OrderServiceInterface
* @param $global_order_id
* @return mixed
*/
public function onlineCancel($order_id);
public function onlineCancel($global_order_id);
/**
* 线上订单退款

2
app/Service/PurchaseLimitService.php

@ -65,7 +65,7 @@ class PurchaseLimitService implements PurchaseLimitServiceInterface
->toArray();
foreach ($goods as $k2 => $v2) {
$ssdb->exec('del', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$v1['user_id'].'_'.$v2['good_id'], $order->global_order_id);
$ssdb->exec('del', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$v1['user_id'].'_'.$v2['good_id']);
var_dump($v1['user_id']);
var_dump($v1['good_id']);
}

Loading…
Cancel
Save