优化:赠送的额度根据设置进行对应倍率的增长
This commit is contained in:
parent
d02ba3c6f3
commit
88498212ff
|
|
@ -205,6 +205,7 @@ class Merchant extends BaseController
|
|||
'sub_mchid',
|
||||
['commission_switch',0],
|
||||
['mer_integral_platform_rate',0],
|
||||
['mer_exchange_quota_multiple',0],
|
||||
['avg_consumption',0],
|
||||
'mer_label',
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use app\common\model\user\ExchangeIntegralRecord;
|
|||
use app\common\model\user\ExchangeQuota;
|
||||
use app\common\model\user\ExchangeQuotaRecord;
|
||||
use app\common\model\user\User;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use think\facade\Log;
|
||||
|
||||
class OrderPaySuccessEvent{
|
||||
|
|
@ -37,17 +38,28 @@ class OrderPaySuccessEvent{
|
|||
// 获取用户当前持有
|
||||
$userHoldInfo = ExchangeQuota::where('uid',$groupOrder->uid)->findOrEmpty();
|
||||
if((int)$userHoldInfo->uid <= 0) $userHoldInfo->uid = $groupOrder->uid;
|
||||
$exchangeQuotaMultiple = (int)systemConfig('exchange_quota_multiple');
|
||||
// 循环处理单个商品
|
||||
$insertData = [];
|
||||
foreach($groupOrder->orderList as $orderInfo){
|
||||
foreach($orderInfo->orderProduct as $orderProductInfo){
|
||||
// 判断:商品是否开启赠送兑换额度 当前商品实际支付的金额=赠送的兑换额度
|
||||
// 判断:商品是否开启赠送兑换额度 赠送的兑换额度 = 当前商品实际支付的金额 * 倍数
|
||||
if($orderProductInfo->product->is_give_quota == 1 && $orderProductInfo->product_price > 0){
|
||||
// 赠送数量计算
|
||||
$giveNum = (float)$orderProductInfo->product_price;
|
||||
$merExchangeQuotaMultiple = (int)app()->make(MerchantRepository::class)
|
||||
->getSearch(['mer_id' => $orderInfo->mer_id])
|
||||
->value('mer_exchange_quota_multiple');
|
||||
if($merExchangeQuotaMultiple > 0){
|
||||
$giveNum = (float)sprintf("%2.f",$giveNum * $merExchangeQuotaMultiple);
|
||||
}else if($exchangeQuotaMultiple > 0) {
|
||||
$giveNum = (float)sprintf("%2.f",$giveNum * $exchangeQuotaMultiple);
|
||||
}
|
||||
// 赠送
|
||||
$changeFront = (float)$userHoldInfo->surplus_quota;
|
||||
$userHoldInfo->total_quota += (float)$orderProductInfo->product_price;// 总额度
|
||||
$userHoldInfo->surplus_quota += (float)$orderProductInfo->product_price;// 剩余额度
|
||||
$userHoldInfo->freeze_quota += (float)$orderProductInfo->product_price;// 冻结额度
|
||||
$userHoldInfo->total_quota += (float)$giveNum;// 总额度
|
||||
$userHoldInfo->surplus_quota += (float)$giveNum;// 剩余额度
|
||||
$userHoldInfo->freeze_quota += (float)$giveNum;// 冻结额度
|
||||
// 记录
|
||||
$insertData[] = [
|
||||
'uid' => $orderProductInfo->uid,
|
||||
|
|
@ -55,7 +67,7 @@ class OrderPaySuccessEvent{
|
|||
'order_id' => $orderProductInfo->order_id,
|
||||
'order_product_id' => $orderProductInfo->order_product_id,
|
||||
'change_type' => 1,
|
||||
'change_quantity' => (float)$orderProductInfo->product_price,
|
||||
'change_quantity' => (float)$giveNum,
|
||||
'change_front' => $changeFront,
|
||||
'change_after' => (float)$userHoldInfo->surplus_quota,
|
||||
'remark' => "购买商品赠送",
|
||||
|
|
|
|||
Loading…
Reference in New Issue