提交代码

This commit is contained in:
manghe 2025-03-23 20:07:02 +00:00
parent 06f919c6f8
commit 886671baf0
4 changed files with 96 additions and 84 deletions

View File

@ -702,7 +702,6 @@ class Goods extends Base
return $this->renderError('金额不足'); return $this->renderError('金额不足');
} }
} }
} }
if ($goodsType['is_deduction'] == 0 && $iszhifu == 0 && $goodsType['pay_wechat'] == 0) { if ($goodsType['is_deduction'] == 0 && $iszhifu == 0 && $goodsType['pay_wechat'] == 0) {
return $this->renderError('请选择支付方式'); return $this->renderError('请选择支付方式');
@ -842,6 +841,7 @@ class Goods extends Base
$is_chou2 = Order::field('id')->where([['is_shou_zhe', '=', 1], ['status', '=', 1], ['user_id', '=', $user['id']]])->find(); $is_chou2 = Order::field('id')->where([['is_shou_zhe', '=', 1], ['status', '=', 1], ['user_id', '=', $user['id']]])->find();
if (!$is_chou && !$is_chou2 && $goods['is_shou_zhe'] == 1) { if (!$is_chou && !$is_chou2 && $goods['is_shou_zhe'] == 1) {
$shou_zhe_price = bcmul("$box_price", "0.5", 2); $shou_zhe_price = bcmul("$box_price", "0.5", 2);
$is_shou_zhe = 1;
} }
} }
$goods['shou_zhe_price'] = $shou_zhe_price; $goods['shou_zhe_price'] = $shou_zhe_price;
@ -853,7 +853,7 @@ class Goods extends Base
$coupon_price = 0; $coupon_price = 0;
# 判断是否可使用优惠券 # 判断是否可使用优惠券
if ($shou_zhe_price <= 0 && !empty($coupon_id) && $goods['type'] != 5 && $goods['type'] != 10 && $goodsType['pay_coupon'] == 1) { if ($shou_zhe_price <= 0 && !empty($coupon_id) && $goodsType['pay_coupon'] == 1) {
# 获取优惠券信息 # 获取优惠券信息
$coupon = CouponReceiveModel::where([ $coupon = CouponReceiveModel::where([
'id' => $coupon_id, 'id' => $coupon_id,
@ -885,90 +885,93 @@ class Goods extends Base
$use_score = 0; # 积分抵扣 $use_score = 0; # 积分抵扣
$zhe = 0; # 会员折扣 $zhe = 0; # 会员折扣
# 积分赏只用积分支付
if ($goods['type'] == 5) { # 对于非积分赏类型,应用会员折扣
$price = 0; if ($shou_zhe_price <= 0) {
$use_score = $order_total; $iszhifu = 0;
if ($user['score'] < $use_score) { # 货币1抵扣
return $this->renderError("积分不足"); if ($use_integral_is == 1 && $goodsType['pay_currency'] == 1) {
$price_in_currency = $price * 100; # 1:100比例
if ($goodsType['is_deduction'] == 1) {
# 抵扣模式
if ($user['integral'] >= $price_in_currency) {
$use_integral = $price_in_currency;
$price = 0;
} else {
$use_integral = $user['integral'];
$price = bcsub("$price", bcdiv("$use_integral", "100", 2), 2);
}
} else {
# 支付模式
if ($user['integral'] >= $price_in_currency) {
$use_integral = $price_in_currency;
$price = 0;
$iszhifu++;
} else {
# 支付模式下货币不足无法抵扣
$use_integral = 0;
return $this->renderError('金额不足');
}
}
} }
} else {
# 对于非积分赏类型,应用会员折扣
if ($shou_zhe_price <= 0) {
# 货币1抵扣 # 余额抵扣
if ($use_integral_is == 1 && $goodsType['pay_currency'] == 1) { if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) {
$price_in_currency = $price * 100; # 1:100比例 if ($goodsType['is_deduction'] == 1) {
if ($goodsType['is_deduction'] == 1) { # 抵扣模式
# 抵扣模式 if ($user['money'] >= $price) {
if ($user['integral'] >= $price_in_currency) { $use_money = $price;
$use_integral = $price_in_currency; $price = 0;
$price = 0;
} else {
$use_integral = $user['integral'];
$price = bcsub("$price", bcdiv("$use_integral", "100", 2), 2);
}
} else { } else {
# 支付模式 $use_money = $user['money'];
if ($user['integral'] >= $price_in_currency) { $price = bcsub("$price", "$use_money", 2);
$use_integral = $price_in_currency; }
$price = 0; } else {
} else { # 支付模式
# 支付模式下货币不足无法抵扣 if ($user['money'] >= $price) {
$use_integral = 0; $use_money = $price;
} $price = 0;
$iszhifu++;
} else {
# 支付模式下余额不足无法抵扣
$use_money = 0;
return $this->renderError('金额不足');
} }
} }
}
# 余额抵扣 # 货币2抵扣
if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { if ($use_money2_is == 1 && $goodsType['pay_currency2'] == 1) {
if ($goodsType['is_deduction'] == 1) { $price_in_currency2 = $price * 100; # 1:100比例
# 抵扣模式 if ($goodsType['is_deduction'] == 1) {
if ($user['money'] >= $price) { # 抵扣模式
$use_money = $price; if (isset($user['money2']) && $user['money2'] >= $price_in_currency2) {
$price = 0; $use_money2 = $price_in_currency2;
} else { $price = 0;
$use_money = $user['money']; } else if (isset($user['money2'])) {
$price = bcsub("$price", "$use_money", 2); $use_money2 = $user['money2'];
} $price = bcsub("$price", bcdiv("$use_money2", "100", 2), 2);
}
} else {
# 支付模式
if (isset($user['money2']) && $user['money2'] >= $price_in_currency2) {
$use_money2 = $price_in_currency2;
$price = 0;
$iszhifu++;
} else { } else {
# 支付模式 # 支付模式下货币2不足无法抵扣
if ($user['money'] >= $price) { $use_money2 = 0;
$use_money = $price; return $this->renderError('金额不足');
$price = 0;
} else {
# 支付模式下余额不足无法抵扣
$use_money = 0;
}
} }
} }
}
# 货币2抵扣 if ($goodsType['is_deduction'] == 0 && $iszhifu == 0 && $goodsType['pay_wechat'] == 0) {
if ($use_money2_is == 1 && $goodsType['pay_currency2'] == 1) { return $this->renderError('请选择支付方式');
$price_in_currency2 = $price * 100; # 1:100比例
if ($goodsType['is_deduction'] == 1) {
# 抵扣模式
if (isset($user['money2']) && $user['money2'] >= $price_in_currency2) {
$use_money2 = $price_in_currency2;
$price = 0;
} else if (isset($user['money2'])) {
$use_money2 = $user['money2'];
$price = bcsub("$price", bcdiv("$use_money2", "100", 2), 2);
}
} else {
# 支付模式
if (isset($user['money2']) && $user['money2'] >= $price_in_currency2) {
$use_money2 = $price_in_currency2;
$price = 0;
} else {
# 支付模式下货币2不足无法抵扣
$use_money2 = 0;
}
}
}
} }
} }
#一番赏锁箱 #一番赏锁箱
if ($goods['type'] == 1 || $goods['type'] == 6 || $goods['type'] == 11) { if ($goods['type'] == 1 || $goods['type'] == 6 || $goods['type'] == 11) {
#盒子id_箱号 #盒子id_箱号
@ -1109,10 +1112,16 @@ class Goods extends Base
$attach = 'order_yfs'; $attach = 'order_yfs';
} elseif ($goods['type'] == 3) { } elseif ($goods['type'] == 3) {
$attach = 'order_lts'; $attach = 'order_lts';
} elseif ($goods['type'] == 6) { } elseif ($goods['type'] == 5) {
$attach = 'order_jfs';
}elseif ($goods['type'] == 6) {
$attach = 'order_lts'; $attach = 'order_lts';
} elseif ($goods['type'] == 11) { } elseif ($goods['type'] == 11) {
$attach = 'order_zzs'; $attach = 'order_zzs';
} elseif ($goods['type'] == 10) {
$attach = 'order_scs';
} else {
$attach = 'order_qts';
} }
$payRes = (new Pay())->wxCreateOrder($order_num, $price, $user['openid'], $body, $attach); $payRes = (new Pay())->wxCreateOrder($order_num, $price, $user['openid'], $body, $attach);
if ($payRes['status'] == 1) { if ($payRes['status'] == 1) {
@ -1130,7 +1139,7 @@ class Goods extends Base
} }
} else { } else {
try { try {
#开盒子 #开盒子 infinite_drawprize_notice
$res[] = (new Notify($this->app))->drawprize_notice($user['id'], $order_id, $goods_id, $num); $res[] = (new Notify($this->app))->drawprize_notice($user['id'], $order_id, $goods_id, $num);
} catch (\Throwable $e) { } catch (\Throwable $e) {
Db::rollback(); Db::rollback();

View File

@ -703,8 +703,7 @@ class Infinite extends Base
'order_num' => $order_num, 'order_num' => $order_num,
]; ];
} }
// writelog(11111111111111, json_encode($res));
// writelog(11111111111111, json_encode($new_data));
if (resCheck($res)) { if (resCheck($res)) {
Db::commit(); Db::commit();
#删除redis #删除redis

View File

@ -49,7 +49,7 @@ class Mall extends Base
'goods' => $goods, 'goods' => $goods,
'price' => round($price, 2), 'price' => round($price, 2),
'integral' => round($price * 100, 2), 'integral' => round($price * 100, 2),
'use_integral' => round($user['integral'], 2), 'use_integral' => round($user['money2'], 2),
'money' => round($user['money'], 2), 'money' => round($user['money'], 2),
]; ];
return $this->renderSuccess("请求成功", $data); return $this->renderSuccess("请求成功", $data);
@ -116,13 +116,10 @@ class Mall extends Base
#盒子单价 #盒子单价
$box_price = $goods['price']; $box_price = $goods['price'];
$order_total = $box_price * 100; $order_total = $box_price * 100;
$integral = $user['integral']; $integral = $user['money2'];
if ($order_total > $integral) { if ($order_total > $integral) {
return $this->renderError("吧唧币不足!!!"); return $this->renderError("余额不足!!!");
} }
$redis = (new \app\common\server\RedisHelper())->getRedis(); $redis = (new \app\common\server\RedisHelper())->getRedis();
$redis_key = "kpw_mall_orderbuy" . '_' . $user['id']; $redis_key = "kpw_mall_orderbuy" . '_' . $user['id'];
$redis_key_info = $redis->get($redis_key); $redis_key_info = $redis->get($redis_key);
@ -146,8 +143,9 @@ class Mall extends Base
'order_zhe_total' => 0,#订单折扣金额 'order_zhe_total' => 0,#订单折扣金额
'price' => 0,#微信支付 'price' => 0,#微信支付
'use_money' => 0,#余额抵扣 'use_money' => 0,#余额抵扣
'use_integral' => $order_total,#吧唧币抵扣 'use_integral' => 0,#吧唧币抵扣
'use_score' => 0,#积分抵扣 'use_score' => 0,#积分抵扣
'use_money2' => $order_total,#积分抵扣
'zhe' => 0,#会员折扣 'zhe' => 0,#会员折扣
'goods_id' => $goods_id, 'goods_id' => $goods_id,
'num' => $num, 'num' => $num,

View File

@ -528,6 +528,9 @@ class Notify extends Base
if ($order['use_score'] > 0) { if ($order['use_score'] > 0) {
$res[] = User::changeScore($order['user_id'], -$order['use_score'], 2, '购买盒子' . $order['goods_title']); $res[] = User::changeScore($order['user_id'], -$order['use_score'], 2, '购买盒子' . $order['goods_title']);
} }
if ($order['use_money2'] > 0) {
$res[] = User::changeMoney2($order['user_id'], -$order['use_money2'], 2, '购买盒子' . $order['goods_title']);
}
#判断一下优惠券 #判断一下优惠券
if (!empty($order['coupon_id'])) { if (!empty($order['coupon_id'])) {
$coupon = CouponReceiveModel::where(['id' => $order['coupon_id'], 'status' => 0])->update(['status' => 1]); $coupon = CouponReceiveModel::where(['id' => $order['coupon_id'], 'status' => 0])->update(['status' => 1]);
@ -1114,6 +1117,9 @@ class Notify extends Base
if ($order['use_integral'] > 0) { if ($order['use_integral'] > 0) {
$res[] = User::changeIntegral($order['user_id'], -$order['use_integral'], 2, '购买盒子' . $order['goods_title']); $res[] = User::changeIntegral($order['user_id'], -$order['use_integral'], 2, '购买盒子' . $order['goods_title']);
} }
if ($order['money2'] > 0) {
$res[] = User::changeMoney2($order['user_id'], -$order['use_money2'], 2, '购买盒子' . $order['goods_title']);
}
#判断一下优惠券 #判断一下优惠券
if (!empty($order['coupon_id'])) { if (!empty($order['coupon_id'])) {