From 3565dff0d1dd96deac7f639edc7dab03177c62b7 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Fri, 24 Mar 2023 11:34:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=85=85=E5=80=BC=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=95=B0=E6=8D=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v1/user/UserRechargeController.php | 3 + crmeb/app/services/pay/PayNotifyServices.php | 3 + .../services/user/UserRechargeServices.php | 58 +++++++++++++------ crmeb/crmeb/services/AliPayService.php | 2 - crmeb/crmeb/services/app/WechatService.php | 3 - crmeb/crmeb/services/pay/storage/AllinPay.php | 3 - .../services/pay/storage/V3WechatPay.php | 4 -- 7 files changed, 47 insertions(+), 29 deletions(-) diff --git a/crmeb/app/api/controller/v1/user/UserRechargeController.php b/crmeb/app/api/controller/v1/user/UserRechargeController.php index 3c4be9601..68d8283b5 100644 --- a/crmeb/app/api/controller/v1/user/UserRechargeController.php +++ b/crmeb/app/api/controller/v1/user/UserRechargeController.php @@ -36,6 +36,9 @@ class UserRechargeController * 用户充值 * @param Request $request * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function recharge(Request $request) { diff --git a/crmeb/app/services/pay/PayNotifyServices.php b/crmeb/app/services/pay/PayNotifyServices.php index 3ca880e72..b160463cb 100644 --- a/crmeb/app/services/pay/PayNotifyServices.php +++ b/crmeb/app/services/pay/PayNotifyServices.php @@ -26,7 +26,10 @@ class PayNotifyServices /** * 订单支付成功之后 * @param string|null $order_id 订单id + * @param string|null $trade_no + * @param string $payType * @return bool + * @throws \Psr\SimpleCache\InvalidArgumentException */ public function wechatProduct(string $order_id = null, string $trade_no = null, string $payType = PayServices::WEIXIN_PAY) { diff --git a/crmeb/app/services/user/UserRechargeServices.php b/crmeb/app/services/user/UserRechargeServices.php index b6e8dead1..9083d5a1d 100644 --- a/crmeb/app/services/user/UserRechargeServices.php +++ b/crmeb/app/services/user/UserRechargeServices.php @@ -104,11 +104,8 @@ class UserRechargeServices extends BaseServices foreach ($list as &$item) { switch ($item['recharge_type']) { - case 'routine': - $item['_recharge_type'] = '小程序充值'; - break; case PayServices::WEIXIN_PAY: - $item['_recharge_type'] = '公众号充值'; + $item['_recharge_type'] = '微信充值'; break; case 'system': $item['_recharge_type'] = '系统充值'; @@ -138,8 +135,8 @@ class UserRechargeServices extends BaseServices $data = []; $data['sumPrice'] = $this->getRechargeSum($where, 'price'); $data['sumRefundPrice'] = $this->getRechargeSum($where, 'refund_price'); - $where['recharge_type'] = 'routine'; - $data['sumRoutinePrice'] = $this->getRechargeSum($where, 'price'); + $where['recharge_type'] = 'alipay'; + $data['sumAlipayPrice'] = $this->getRechargeSum($where, 'price'); $where['recharge_type'] = 'weixin'; $data['sumWeixinPrice'] = $this->getRechargeSum($where, 'price'); return [ @@ -158,14 +155,14 @@ class UserRechargeServices extends BaseServices 'col' => 6, ], [ - 'name' => '小程序充值金额', + 'name' => '支付宝充值金额', 'field' => '元', - 'count' => $data['sumRoutinePrice'], + 'count' => $data['sumAlipayPrice'], 'className' => 'logo-bitcoin', 'col' => 6, ], [ - 'name' => '公众号充值金额', + 'name' => '微信充值金额', 'field' => '元', 'count' => $data['sumWeixinPrice'], 'className' => 'ios-bicycle', @@ -174,9 +171,14 @@ class UserRechargeServices extends BaseServices ]; } - /**退款表单 - * @param $id - * @return mixed|void + /** + * 退款表单 + * @param int $id + * @return array + * @throws \FormBuilder\Exception\FormBuilderException + * @author 吴汐 + * @email 442384644@qq.com + * @date 2023/03/24 */ public function refund_edit(int $id) { @@ -196,15 +198,17 @@ class UserRechargeServices extends BaseServices $f = array(); $f[] = Form::input('order_id', '退款单号', $UserRecharge->getData('order_id'))->disabled(true); $f[] = Form::radio('refund_price', '状态', 1)->options([['label' => '本金(扣赠送余额)', 'value' => 1], ['label' => '仅本金', 'value' => 0]]); -// $f[] = Form::number('refund_price', '退款金额', (float)$UserRecharge->getData('price'))->precision(2)->min(0)->max($UserRecharge->getData('price')); return create_form('编辑', $f, Url::buildUrl('/finance/recharge/' . $id), 'PUT'); } /** * 退款操作 * @param int $id - * @param $refund_price + * @param string $refund_price * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function refund_update(int $id, string $refund_price) { @@ -314,6 +318,9 @@ class UserRechargeServices extends BaseServices * @param int $uid * @param $price * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function importNowMoney(int $uid, $price) { @@ -340,7 +347,7 @@ class UserRechargeServices extends BaseServices //写入充值记录 $rechargeInfo = [ 'uid' => $uid, - 'order_id' => $this->getOrderId(), + 'order_id' => app()->make(StoreOrderCreateServices::class)->getNewOrderId('cz'), 'recharge_type' => 'balance', 'price' => $price, 'give_price' => 0, @@ -381,7 +388,15 @@ class UserRechargeServices extends BaseServices /** * 申请充值 * @param int $uid + * @param $price + * @param $recharId + * @param $type + * @param $from + * @param bool $renten * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function recharge(int $uid, $price, $recharId, $type, $from, bool $renten = false) { @@ -437,8 +452,13 @@ class UserRechargeServices extends BaseServices } /** - * //TODO用户充值成功后 + * 用户充值成功后 * @param $orderId + * @param array $other + * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function rechargeSuccess($orderId, array $other = []) { @@ -475,8 +495,12 @@ class UserRechargeServices extends BaseServices return true; } - /**根据查询用户充值金额 + /** + * 根据查询用户充值金额 * @param array $where + * @param string $rechargeSumField + * @param string $selectType + * @param string $group * @return float|int */ public function getRechargeMoneyByWhere(array $where, string $rechargeSumField, string $selectType, string $group = "") diff --git a/crmeb/crmeb/services/AliPayService.php b/crmeb/crmeb/services/AliPayService.php index aab7e43ca..f35311181 100644 --- a/crmeb/crmeb/services/AliPayService.php +++ b/crmeb/crmeb/services/AliPayService.php @@ -13,14 +13,12 @@ namespace crmeb\services; use Alipay\EasySDK\Payment\Wap\Models\AlipayTradeWapPayResponse; use app\services\pay\PayServices; -use crmeb\utils\Hook; use think\facade\Event; use think\facade\Log; use think\facade\Route as Url; use Alipay\EasySDK\Kernel\Config; use Alipay\EasySDK\Kernel\Factory; use crmeb\exceptions\PayException; -use app\services\pay\PayNotifyServices; use Alipay\EasySDK\Kernel\Util\ResponseChecker; /** diff --git a/crmeb/crmeb/services/app/WechatService.php b/crmeb/crmeb/services/app/WechatService.php index b732f623e..41c9e47bc 100644 --- a/crmeb/crmeb/services/app/WechatService.php +++ b/crmeb/crmeb/services/app/WechatService.php @@ -12,12 +12,10 @@ namespace crmeb\services\app; use app\services\message\wechat\MessageServices; -use app\services\order\StoreOrderServices; use app\services\pay\PayServices; use app\services\wechat\WechatMessageServices; use app\services\wechat\WechatReplyServices; use crmeb\exceptions\AdminException; -use app\services\pay\PayNotifyServices; use crmeb\exceptions\ApiException; use crmeb\services\easywechat\Application; use EasyWeChat\Message\Article; @@ -33,7 +31,6 @@ use Symfony\Component\HttpFoundation\Request; use think\facade\Event; use think\facade\Log; use think\Response; -use crmeb\utils\Hook; use think\facade\Cache; use crmeb\services\SystemConfigService; diff --git a/crmeb/crmeb/services/pay/storage/AllinPay.php b/crmeb/crmeb/services/pay/storage/AllinPay.php index b756f3357..04afa521d 100644 --- a/crmeb/crmeb/services/pay/storage/AllinPay.php +++ b/crmeb/crmeb/services/pay/storage/AllinPay.php @@ -13,14 +13,11 @@ namespace crmeb\services\pay\storage; - -use app\services\pay\PayNotifyServices; use app\services\pay\PayServices; use crmeb\exceptions\PayException; use crmeb\services\pay\BasePay; use crmeb\services\pay\PayInterface; use crmeb\services\pay\extend\allinpay\AllinPay as AllinPayService; -use crmeb\utils\Hook; use EasyWeChat\Payment\Order; use think\facade\Event; diff --git a/crmeb/crmeb/services/pay/storage/V3WechatPay.php b/crmeb/crmeb/services/pay/storage/V3WechatPay.php index 60d0af760..c384d2bc6 100644 --- a/crmeb/crmeb/services/pay/storage/V3WechatPay.php +++ b/crmeb/crmeb/services/pay/storage/V3WechatPay.php @@ -13,18 +13,14 @@ namespace crmeb\services\pay\storage; -use app\services\pay\PayNotifyServices; use app\services\pay\PayServices; -use app\services\wechat\WechatMessageServices; use crmeb\exceptions\PayException; use crmeb\services\app\MiniProgramService; use crmeb\services\easywechat\Application; use crmeb\services\pay\BasePay; use crmeb\services\pay\PayInterface; -use crmeb\utils\Hook; use EasyWeChat\Payment\Order; use think\facade\Event; -use think\facade\Log; /** * Class 微信支付v3 From 14fa9815392feb95d4c634baf45b5a50d8dc504d Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Fri, 24 Mar 2023 11:37:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B5=84=E9=87=91=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=8E=E9=93=B6=E8=A1=8C=E8=BD=AC=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/services/pay/PayServices.php | 6 +++++- crmeb/app/services/statistic/CapitalFlowServices.php | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crmeb/app/services/pay/PayServices.php b/crmeb/app/services/pay/PayServices.php index e896d63be..acb83409a 100644 --- a/crmeb/app/services/pay/PayServices.php +++ b/crmeb/app/services/pay/PayServices.php @@ -40,6 +40,9 @@ class PayServices //好友代付 const FRIEND = 'friend'; + //银行转账 + const BANK = 'bank'; + //支付方式 const PAY_TYPE = [ PayServices::WEIXIN_PAY => '微信支付', @@ -47,7 +50,8 @@ class PayServices PayServices::OFFLINE_PAY => '线下支付', PayServices::ALIAPY_PAY => '支付宝', PayServices::FRIEND => '好友代付', - PayServices::ALLIN_PAY => '通联支付' + PayServices::ALLIN_PAY => '通联支付', + PayServices::BANK => '银行转账', ]; /** diff --git a/crmeb/app/services/statistic/CapitalFlowServices.php b/crmeb/app/services/statistic/CapitalFlowServices.php index 09dc0bcd3..0b5877317 100644 --- a/crmeb/app/services/statistic/CapitalFlowServices.php +++ b/crmeb/app/services/statistic/CapitalFlowServices.php @@ -104,6 +104,9 @@ class CapitalFlowServices extends BaseServices * 获取资金流水 * @param $where * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function getFlowList($where) { From 4349a46a6df8893d2d7babd6a0f3e8ad64dc07b0 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Fri, 24 Mar 2023 12:01:34 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E4=B8=8D=E6=89=BE=E6=8B=86=E5=88=86=E7=9A=84=E4=B8=BB?= =?UTF-8?q?=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/services/order/StoreCartServices.php | 5 +++-- crmeb/app/services/order/StoreOrderRefundServices.php | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crmeb/app/services/order/StoreCartServices.php b/crmeb/app/services/order/StoreCartServices.php index d4efe3568..9367bd849 100644 --- a/crmeb/app/services/order/StoreCartServices.php +++ b/crmeb/app/services/order/StoreCartServices.php @@ -679,6 +679,7 @@ class StoreCartServices extends BaseServices * @param $num * @param $new * @return bool + * @throws \ReflectionException */ public function checkLimit($uid, $product_id, $num, $new) { @@ -701,8 +702,8 @@ class StoreCartServices extends BaseServices } } else if ($limitInfo['limit_type'] == 2) { $cartNum = $this->dao->sum(['uid' => $uid, 'product_id' => $product_id], 'cart_num'); - $orderPayNum = $orderCartServices->sum(['uid' => $uid, 'product_id' => $product_id], 'cart_num'); - $orderRefundNum = $orderCartServices->sum(['uid' => $uid, 'product_id' => $product_id], 'refund_num'); + $orderPayNum = $orderCartServices->sum(['uid' => $uid, 'product_id' => $product_id, 'pid' => 0], 'cart_num'); + $orderRefundNum = $orderCartServices->sum(['uid' => $uid, 'product_id' => $product_id, 'pid' => 0], 'refund_num'); $orderNum = $orderPayNum - $orderRefundNum; if (($num + $orderNum + $cartNum) > $limitInfo['limit_num']) { throw new ApiException(410240, ['limit' => $limitInfo['limit_num'], 'pay_num' => $orderNum]); diff --git a/crmeb/app/services/order/StoreOrderRefundServices.php b/crmeb/app/services/order/StoreOrderRefundServices.php index 3fd06be86..97dc9f9ed 100644 --- a/crmeb/app/services/order/StoreOrderRefundServices.php +++ b/crmeb/app/services/order/StoreOrderRefundServices.php @@ -435,9 +435,9 @@ class StoreOrderRefundServices extends BaseServices $res = true; //回退优惠卷 拆分子订单不退优惠券 if (!$order['pid'] && $order['coupon_id'] && $order['coupon_price']) { - /** @var StoreCouponUserServices $coumonUserServices */ - $coumonUserServices = app()->make(StoreCouponUserServices::class); - $res = $res && $coumonUserServices->recoverCoupon((int)$order['coupon_id']); + /** @var StoreCouponUserServices $couponUserServices */ + $couponUserServices = app()->make(StoreCouponUserServices::class); + $res = $couponUserServices->recoverCoupon((int)$order['coupon_id']); $statusService->save([ 'oid' => $order['id'], 'change_type' => 'coupon_back',