添加:消费返利 - 复购流程
This commit is contained in:
parent
3b36561999
commit
3c53f8a4ab
|
|
@ -17,6 +17,7 @@ use app\common\models\Member;
|
|||
use app\common\models\MemberGroup;
|
||||
use app\common\models\MemberLevel;
|
||||
use app\common\models\Order;
|
||||
use app\common\models\OrderGoods;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use app\common\facades\Setting;
|
||||
|
|
@ -588,9 +589,15 @@ class Privilege extends BaseModel
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 消费返利商品判断
|
||||
/**
|
||||
* Common: 消费返利商品判断 - 是否允许购买
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/16 11:01
|
||||
* @param $member
|
||||
* @param $num
|
||||
* @return false|void
|
||||
* @throws AppException
|
||||
*/
|
||||
public function validateRebate($member,$num){
|
||||
// 判断:是否开启消费返利
|
||||
$goodsRebate = GoodsRebate::where('goods_id',$this->goods_id)->first();
|
||||
|
|
@ -625,6 +632,14 @@ class Privilege extends BaseModel
|
|||
$limitTime = strtotime(date("Y-m-d H:i:s",$maxTime)." +{$repurchase_day} day");
|
||||
// 判断:最后复购时间 小于等于 当前时间,超出复购时间,禁止复购
|
||||
if($limitTime <= time()) throw new AppException('已超过复购时间');
|
||||
// 是否已经存在复购订单
|
||||
$isHas = (int)OrderGoods::where('is_rebate',1)
|
||||
->where('created_at', '>', $maxTime)// 在最后一次返利后的订单
|
||||
->where('created_at', '<=', $limitTime)// 在复购时间内的订单
|
||||
->where('goods_id', $this->goods_id)// 同一个商品
|
||||
->where('uid', $member->uid)// 同一个用户
|
||||
->value('id');
|
||||
if($isHas > 0) throw new AppException('请勿重复复购!');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ use Yunshop\CulturalSpace\models\CulturalFund;
|
|||
use Yunshop\CulturalSpace\models\GoodsCulturalSpace;
|
||||
use Yunshop\PointMall\models\PointMallGoodsModel;
|
||||
use Yunshop\PointMall\models\PointMallGoodsOptionsModel;
|
||||
use Yunshop\Rebate\models\GoodsRebate;
|
||||
use Yunshop\Rebate\models\Rebate;
|
||||
|
||||
/**
|
||||
* Class PreOrderGoods
|
||||
|
|
@ -174,6 +176,27 @@ class PreOrderGoods extends OrderGoods
|
|||
$this->legumes_exchange_price = $legumes_exchange_price;
|
||||
$this->use_legumes_exchange = (float)ceil(sprintf("%.2f",$legumes_exchange_price / $current_fee));
|
||||
}
|
||||
// 判断:是否开启消费返利
|
||||
$this->is_rebate = 0;
|
||||
$goodsRebate = GoodsRebate::where('goods_id',$this->goods_id)->first();
|
||||
if($goodsRebate->is_open == 1){
|
||||
// 判断:当前返利记录是否已经失效
|
||||
$endTime = Rebate::where('uid',(int)$this->uid)
|
||||
->where('goods_id', $this->goods_id)
|
||||
->max('reality_thaw_time');
|
||||
// 不存在返利记录 原价购买
|
||||
if(empty($endTime)) return $this->price;
|
||||
// 存在返利记录 判断最后一条信息的状态
|
||||
$endInfo = Rebate::where('uid', (int)$this->uid)
|
||||
->where('goods_id', $this->goods_id)
|
||||
->where('reality_thaw_time', $endTime)
|
||||
->first();
|
||||
// 已失效 原价购买
|
||||
if($endInfo->status == 2) $this->is_rebate = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 判断:当前商品是否存在积分商品设置
|
||||
/*if((int)$this->pointGoods->id > 0){
|
||||
$this->point_status = 1;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ namespace app\frontend\modules\orderGoods\price\option;
|
|||
* Time: 下午6:04
|
||||
*/
|
||||
|
||||
use app\common\exceptions\AppException;
|
||||
use app\common\facades\Setting;
|
||||
use app\common\helpers\Serializer;
|
||||
use app\frontend\models\order\PreOrderCoinExchange;
|
||||
use app\frontend\models\orderGoods\PreOrderGoodsCoinExchange;
|
||||
|
|
@ -26,6 +28,8 @@ use app\frontend\modules\orderGoods\price\adapter\GoodsAdapterManager;
|
|||
use app\frontend\modules\orderGoods\taxFee\BaseTaxFee;
|
||||
use Yunshop\CulturalSpace\models\CulturalFund;
|
||||
use Yunshop\CulturalSpace\models\GoodsCulturalSpace;
|
||||
use Yunshop\Rebate\models\GoodsRebate;
|
||||
use Yunshop\Rebate\models\Rebate;
|
||||
|
||||
abstract class BaseOrderGoodsPrice extends OrderGoodsPrice
|
||||
{
|
||||
|
|
@ -99,11 +103,33 @@ abstract class BaseOrderGoodsPrice extends OrderGoodsPrice
|
|||
if((int)request()->input('is_legumes_exchange') == 1) return 0;
|
||||
if (isset($this->price)) return $this->price;
|
||||
if ($this->isCoinExchange()) return 0;
|
||||
|
||||
// 商品销售价 - 等级优惠金额
|
||||
$this->price = $this->getGoodsPrice();
|
||||
|
||||
$this->price = max($this->price, 0);
|
||||
// 判断:是否开启消费返利
|
||||
$goodsRebate = GoodsRebate::where('goods_id',$this->orderGoods->goods_id)->first();
|
||||
if($goodsRebate->is_open == 1){
|
||||
// 判断:当前返利记录是否已经失效
|
||||
$endTime = Rebate::where('uid', $this->orderGoods->uid)
|
||||
->where('goods_id', $this->orderGoods->goods_id)
|
||||
->max('reality_thaw_time');
|
||||
// 不存在返利记录 原价购买
|
||||
if(empty($endTime)) return $this->price;
|
||||
// 存在返利记录 判断最后一条信息的状态
|
||||
$endInfo = Rebate::where('uid', $this->orderGoods->uid)
|
||||
->where('goods_id', $this->orderGoods->goods_id)
|
||||
->where('reality_thaw_time', $endTime)
|
||||
->first();
|
||||
// 已失效 原价购买
|
||||
if($endInfo->status == 2){
|
||||
// 复购
|
||||
$endInfo = $endInfo->toArray();
|
||||
$goodsRebate = $goodsRebate->toArray();
|
||||
$quarter = $goodsRebate['quarter_list'][$endInfo['quarter']];
|
||||
$this->price = $quarter['repurchase_money'] ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->price;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ class Rebate extends BaseModel{
|
|||
])
|
||||
->leftjoin('yz_goods_rebate','yz_goods_rebate.goods_id','=','yz_order_goods.goods_id')
|
||||
->where('yz_order_goods.order_id',$orderId)
|
||||
->where('yz_order_goods.is_rebate',0)
|
||||
->where('yz_goods_rebate.is_open', 1)
|
||||
->get()
|
||||
->makeHidden(['order','after_sales','buttons'])
|
||||
|
|
|
|||
Loading…
Reference in New Issue