From 886671baf0937fa49899d5a3d27229ca9b33132c Mon Sep 17 00:00:00 2001 From: manghe Date: Sun, 23 Mar 2025 20:07:02 +0000 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Goods.php | 159 +++++++++++++++++--------------- app/api/controller/Infinite.php | 3 +- app/api/controller/Mall.php | 12 +-- app/api/controller/Notify.php | 6 ++ 4 files changed, 96 insertions(+), 84 deletions(-) diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 4f82643..1f07b35 100755 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -702,7 +702,6 @@ class Goods extends Base return $this->renderError('金额不足'); } } - } if ($goodsType['is_deduction'] == 0 && $iszhifu == 0 && $goodsType['pay_wechat'] == 0) { 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(); if (!$is_chou && !$is_chou2 && $goods['is_shou_zhe'] == 1) { $shou_zhe_price = bcmul("$box_price", "0.5", 2); + $is_shou_zhe = 1; } } $goods['shou_zhe_price'] = $shou_zhe_price; @@ -853,7 +853,7 @@ class Goods extends Base $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([ 'id' => $coupon_id, @@ -885,90 +885,93 @@ class Goods extends Base $use_score = 0; # 积分抵扣 $zhe = 0; # 会员折扣 - # 积分赏只用积分支付 - if ($goods['type'] == 5) { - $price = 0; - $use_score = $order_total; - if ($user['score'] < $use_score) { - return $this->renderError("积分不足"); + + # 对于非积分赏类型,应用会员折扣 + if ($shou_zhe_price <= 0) { + $iszhifu = 0; + # 货币1抵扣 + 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) { - $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); - } + # 余额抵扣 + if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { + if ($goodsType['is_deduction'] == 1) { + # 抵扣模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; } else { - # 支付模式 - if ($user['integral'] >= $price_in_currency) { - $use_integral = $price_in_currency; - $price = 0; - } else { - # 支付模式下货币不足无法抵扣 - $use_integral = 0; - } + $use_money = $user['money']; + $price = bcsub("$price", "$use_money", 2); + } + } else { + # 支付模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; + $iszhifu++; + } else { + # 支付模式下余额不足无法抵扣 + $use_money = 0; + return $this->renderError('金额不足'); } } + } - # 余额抵扣 - if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { - if ($goodsType['is_deduction'] == 1) { - # 抵扣模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - } else { - $use_money = $user['money']; - $price = bcsub("$price", "$use_money", 2); - } + # 货币2抵扣 + if ($use_money2_is == 1 && $goodsType['pay_currency2'] == 1) { + $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; + $iszhifu++; } else { - # 支付模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - } else { - # 支付模式下余额不足无法抵扣 - $use_money = 0; - } + # 支付模式下货币2不足无法抵扣 + $use_money2 = 0; + return $this->renderError('金额不足'); } } + } - # 货币2抵扣 - if ($use_money2_is == 1 && $goodsType['pay_currency2'] == 1) { - $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 ($goodsType['is_deduction'] == 0 && $iszhifu == 0 && $goodsType['pay_wechat'] == 0) { + return $this->renderError('请选择支付方式'); } } + #一番赏锁箱 if ($goods['type'] == 1 || $goods['type'] == 6 || $goods['type'] == 11) { #盒子id_箱号 @@ -1109,10 +1112,16 @@ class Goods extends Base $attach = 'order_yfs'; } elseif ($goods['type'] == 3) { $attach = 'order_lts'; - } elseif ($goods['type'] == 6) { + } elseif ($goods['type'] == 5) { + $attach = 'order_jfs'; + }elseif ($goods['type'] == 6) { $attach = 'order_lts'; } elseif ($goods['type'] == 11) { $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); if ($payRes['status'] == 1) { @@ -1130,7 +1139,7 @@ class Goods extends Base } } else { try { - #开盒子 + #开盒子 infinite_drawprize_notice $res[] = (new Notify($this->app))->drawprize_notice($user['id'], $order_id, $goods_id, $num); } catch (\Throwable $e) { Db::rollback(); diff --git a/app/api/controller/Infinite.php b/app/api/controller/Infinite.php index eb1f1c4..71da83b 100755 --- a/app/api/controller/Infinite.php +++ b/app/api/controller/Infinite.php @@ -703,8 +703,7 @@ class Infinite extends Base 'order_num' => $order_num, ]; } - // writelog(11111111111111, json_encode($res)); -// writelog(11111111111111, json_encode($new_data)); + if (resCheck($res)) { Db::commit(); #删除redis diff --git a/app/api/controller/Mall.php b/app/api/controller/Mall.php index 6e87098..012a969 100755 --- a/app/api/controller/Mall.php +++ b/app/api/controller/Mall.php @@ -49,7 +49,7 @@ class Mall extends Base 'goods' => $goods, 'price' => round($price, 2), 'integral' => round($price * 100, 2), - 'use_integral' => round($user['integral'], 2), + 'use_integral' => round($user['money2'], 2), 'money' => round($user['money'], 2), ]; return $this->renderSuccess("请求成功", $data); @@ -116,13 +116,10 @@ class Mall extends Base #盒子单价 $box_price = $goods['price']; $order_total = $box_price * 100; - $integral = $user['integral']; + $integral = $user['money2']; if ($order_total > $integral) { - return $this->renderError("吧唧币不足!!!"); + return $this->renderError("余额不足!!!"); } - - - $redis = (new \app\common\server\RedisHelper())->getRedis(); $redis_key = "kpw_mall_orderbuy" . '_' . $user['id']; $redis_key_info = $redis->get($redis_key); @@ -146,8 +143,9 @@ class Mall extends Base 'order_zhe_total' => 0,#订单折扣金额 'price' => 0,#微信支付 'use_money' => 0,#余额抵扣 - 'use_integral' => $order_total,#吧唧币抵扣 + 'use_integral' => 0,#吧唧币抵扣 'use_score' => 0,#积分抵扣 + 'use_money2' => $order_total,#积分抵扣 'zhe' => 0,#会员折扣 'goods_id' => $goods_id, 'num' => $num, diff --git a/app/api/controller/Notify.php b/app/api/controller/Notify.php index 6fb5ac3..c71245a 100755 --- a/app/api/controller/Notify.php +++ b/app/api/controller/Notify.php @@ -528,6 +528,9 @@ class Notify extends Base if ($order['use_score'] > 0) { $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'])) { $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) { $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'])) {