Compare commits
No commits in common. "main" and "develop" have entirely different histories.
|
@ -1 +1 @@
|
||||||
APP_DEBUG=true
DEFAULT_TIMEZONE=Asia/Shanghai
IS_TEST=true
[DATABASE]
TYPE=mysql
HOSTNAME=192.168.6.193
DATABASE=cmb_youku
USERNAME=root
PASSWORD=lansexiongdi
HOSTPORT=3307
CHARSET=utf8
DEBUG=true
PREFIX=
[FILESYSTEM]
DRIVER=public
[REDIS]
IS_TEST=true
DATABASE=cmb_youku
port=6379
IS_TEST=true
PASSWORD=lansexiongdi
IS_TEST=true
HOSTPORT=3307
IS_TEST=true
CHARSET=utf8
expire=7200
timeout=3600
[CACHE]
DRIVER=redis
[DATABASE]
HOSTNAME=192.168.6.193
[DATABASE]
DATABASE=cmb_youku
[DATABASE]
DATABASE=cmb_youku
[DATABASE]
USERNAME=root
[DATABASE]
PASSWORD=lansexiongdi
APP_KEY=
SMS_URL=
TYPE=mysql
SIGN_NAME=
TYPE=mysql
[DATABASE]
[ALISMS]
TYPE=mysql
HOSTNAME=192.168.6.193
TYPE=mysql
DATABASE=cmb_youku
TYPE=mysql
USERNAME=root
TYPE=mysql
PASSWORD=lansexiongdi
TYPE=mysql
HOSTPORT=3307
TYPE=mysql
CHARSET=utf8
HOSTNAME=192.168.6.193
HOSTNAME=192.168.6.193
IS_TEST=true
HOSTNAME=192.168.6.193
[DATABASE]
HOSTNAME=192.168.6.193
TYPE=mysql
version=1.0
merchant_key=8db16e8cc8363ed4eb4c14f9520bcc32
notify_url=
[ALISMS]
APP_ID=LTAI5tHw7KKtobnafvkUpqRZ
APP_KEY=3cPlaCbfwc9BTqIXlvo5up5WaYgIWs
HOSTNAME=192.168.6.193
CHARSET=utf8
TEMPLATE_SMS_CODE=SMS_467595457
TEMPLATE_AGREEMENT_PAY_CODE=SMS_469030240
#SIGN_NAME=蓝色兄弟
DATABASE=cmb_youku
TYPE=mysql
TEMPLATE_ISSUE_CODE=
[CMB]
CONTINUE_PRICE=7.5
CONTINUE_BONUS=9
DATABASE=cmb_youku
HOSTPORT=3307
USE_BONUS_MOUTH=1
AGREE_PAY_DAY=1
API_HOST=https://sandbox.cdcc.cmbchina.com/AccessGateway/transIn/
MID=8258fe390d8e39719619f41d3e62aebb
AID=edea4b87342a4d6f9a697265dc9d26f1
SM2_PRI_KEY=e7d00ecae794e849d3425959ad7b288d18391cf5ce6cd740960a0f3092d5f0f6
SM2_PUB_KEY=04e59bc357ff33a4ca5e31aac8ebdbdb1e1d0dc1d719c9341722754804b12e49ed2b83f0a533faa9c1de59e8f5c0d9cfb2df7e7f2303096e507dccac26f7202289
SM2_CMB_PUB_KEY=0416445bc16cbf42e47002ad9fe7c7af67d902b48be1eb69b98f6a006b0918630e1127f5f2fff83b2ecb30fc7fd72c34c33f37c7c355dffde3589f66800f0036ca
AGREE_NOTIFY_URL=http://211.137.105.198:8041/agreement/notify
PAY_NOTIFY_URL=http://211.137.105.198:8041/agreement/payNotify
USERNAME=root
CHARSET=utf8
RECHARGE_NOTIFY_URL=http://211.137.105.198:8041/order/rechargeNotify
|
APP_DEBUG=true
DEFAULT_TIMEZONE=Asia/Shanghai
[DATABASE]
TYPE=mysql
HOSTNAME=192.168.6.193
DATABASE=cmb_youku
USERNAME=root
PASSWORD=lansexiongdi
HOSTPORT=3307
CHARSET=utf8
DEBUG=true
PREFIX=
[FILESYSTEM]
DRIVER=public
[REDIS]
PASSWORD=lansexiongdi
IS_TEST=true
PORT=6379
PASSWORD=lansexiongdi
TYPE=mysql
IS_TEST=true
IS_TEST=true
PASSWORD=lansexiongdi
PASSWORD=lansexiongdi
HOSTNAME=192.168.6.193
PASSWORD=lansexiongdi
DATABASE=cmb_youku
[DATABASE]
[DATABASE]
[DATABASE]
TYPE=mysql
[DATABASE]
HOSTNAME=192.168.6.193
TYPE=mysql
CHARSET=utf8
PASSWORD=lansexiongdi
USERNAME=root
PASSWORD=lansexiongdi
PASSWORD=lansexiongdi
PASSWORD=lansexiongdi
HOSTPORT=3307
PASSWORD=lansexiongdi
CHARSET=utf8
HOSTPORT=3307
HOSTPORT=3307
IS_TEST=true
HOSTPORT=3307
[DATABASE]
HOSTPORT=3307
TYPE=mysql
[ALISMS]
APP_ID=LTAI5tHw7KKtobnafvkUpqRZ
APP_KEY=3cPlaCbfwc9BTqIXlvo5up5WaYgIWs
HOSTPORT=3307
HOSTNAME=192.168.6.193
HOSTPORT=3307
DATABASE=cmb_youku
TEMPLATE_ISSUE_CODE=
[CMB]
CONTINUE_PRICE=7.5
CONTINUE_BONUS=9
HOSTPORT=3307
USERNAME=root
USE_BONUS_MOUTH=1
AGREE_PAY_DAY=31
API_HOST=https://open.cmbchina.com/AccessGateway/transIn/
MID=cd9ec20f902d3d4ab6d63127c44e7897
AID=b32894073a844a38a10abe465cae8b34
SM2_PRI_KEY=e7d00ecae794e849d3425959ad7b288d18391cf5ce6cd740960a0f3092d5f0f6
SM2_PUB_KEY=04e59bc357ff33a4ca5e31aac8ebdbdb1e1d0dc1d719c9341722754804b12e49ed2b83f0a533faa9c1de59e8f5c0d9cfb2df7e7f2303096e507dccac26f7202289
SM2_CMB_PUB_KEY=040bd3ed2b542616e5a8ac810605f10d2bf222c9f78cbb4405e74b987e0ca3ce4167edb67afd9d83199d68749195cde6e3b0ef68c119608fa5c1780225ae5c9ce5
AGREE_NOTIFY_URL=https://youkucmb.iq1.cn/api/agreement/notify
PAY_NOTIFY_URL=https://youkucmb.iq1.cn/api/agreement/payNotify
CHARSET=utf8
HOSTNAME=192.168.6.193
RECHARGE_NOTIFY_URL=https://youkucmb.iq1.cn/api/order/rechargeNotify
|
|
@ -0,0 +1,40 @@
|
||||||
|
FROM php:7.4-fpm-alpine
|
||||||
|
|
||||||
|
RUN curl -sfL https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
|
||||||
|
&& chmod +x /usr/bin/composer \
|
||||||
|
&& composer self-update --clean-backups 2.0.8 \
|
||||||
|
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||||
|
&& apk update \
|
||||||
|
&& apk add --no-cache tzdata \
|
||||||
|
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||||
|
&& echo "Asia/Shanghai" > /etc/timezone \
|
||||||
|
&& apk add --no-cache libstdc++ protobuf make autoconf wget gcc libc-dev automake libtool openssh openrc git supervisor\
|
||||||
|
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS curl-dev openssl-dev pcre-dev pcre2-dev zlib-dev \
|
||||||
|
&& wget https://lsxd-dockerfile.oss-cn-chengdu.aliyuncs.com/grpc_php_plugin -P /usr/bin/ \
|
||||||
|
&& chmod +x /usr/bin/grpc_php_plugin \
|
||||||
|
&& docker-php-ext-install sockets mysqli pdo_mysql \
|
||||||
|
&& echo -e "yes\nyes\nyes\nyes\nyes\nyes\n" | pecl install swoole-4.8.0 \
|
||||||
|
&& docker-php-ext-enable swoole \
|
||||||
|
&& echo -e "yes\n" | pecl install xlswriter \
|
||||||
|
&& docker-php-ext-enable xlswriter \
|
||||||
|
&& apk add libzip libzip-dev \
|
||||||
|
&& docker-php-ext-configure zip --with-zip \
|
||||||
|
&& docker-php-ext-install -j$(nproc) zip \
|
||||||
|
&& apk add libwebp-dev libjpeg libjpeg-turbo-dev libpng libpng-dev freetype freetype-dev \
|
||||||
|
&& docker-php-ext-configure gd --with-webp=/usr/include/webp --with-jpeg=/usr/include --with-freetype=/usr/include/freetype2/ \
|
||||||
|
&& docker-php-ext-install -j$(nproc) gd \
|
||||||
|
&& pecl install redis-5.3.4 \
|
||||||
|
&& docker-php-ext-enable redis \
|
||||||
|
&& apk del .build-deps
|
||||||
|
|
||||||
|
RUN docker-php-ext-install bcmath
|
||||||
|
|
||||||
|
ADD ./startup.sh /opt/startup.sh
|
||||||
|
RUN sed -i 's/\r//g' /opt/startup.sh
|
||||||
|
|
||||||
|
RUN mkdir "/var/log/supervisor"
|
||||||
|
ADD ./supervisord.conf /etc/supervisord.conf
|
||||||
|
|
||||||
|
EXPOSE 9000 80 22
|
||||||
|
WORKDIR /var/project
|
||||||
|
CMD ["sh", "/opt/startup.sh"]
|
|
@ -54,5 +54,3 @@ All rights reserved。
|
||||||
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
|
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
|
||||||
|
|
||||||
更多细节参阅 [LICENSE.txt](LICENSE.txt)
|
更多细节参阅 [LICENSE.txt](LICENSE.txt)
|
||||||
|
|
||||||
招商优酷API
|
|
|
@ -10,7 +10,6 @@ use think\Collection;
|
||||||
use think\console\Command;
|
use think\console\Command;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
use think\facade\Log;
|
|
||||||
|
|
||||||
class AgreementPay extends Command
|
class AgreementPay extends Command
|
||||||
{
|
{
|
||||||
|
@ -58,7 +57,6 @@ class AgreementPay extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Log::info(sprintf("扣款job执行情况:执行成功,累计 %s, 受理成功 %s, 失败 %s", $this->count, $this->successCount, $this->failedCount));
|
|
||||||
$output->writeln(sprintf("执行成功,累计 %s, 受理成功 %s, 失败 %s", $this->count, $this->successCount, $this->failedCount));
|
$output->writeln(sprintf("执行成功,累计 %s, 受理成功 %s, 失败 %s", $this->count, $this->successCount, $this->failedCount));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,80 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace app\cmd;
|
|
||||||
|
|
||||||
use app\config\BusinessCacheKey;
|
|
||||||
use app\model\Order;
|
|
||||||
use app\model\Sign;
|
|
||||||
use app\service\PayService;
|
|
||||||
use app\service\util\RedisService;
|
|
||||||
use app\sms\AliSms;
|
|
||||||
use think\Collection;
|
|
||||||
use think\console\Command;
|
|
||||||
use think\console\Input;
|
|
||||||
use think\console\Output;
|
|
||||||
use think\facade\Log;
|
|
||||||
|
|
||||||
class AgreementPaySendSms extends Command
|
|
||||||
{
|
|
||||||
protected int $count = 0;
|
|
||||||
protected int $successCount = 0;
|
|
||||||
protected int $failedCount = 0;
|
|
||||||
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
$this->setName('agreementPaySendSms')
|
|
||||||
->setDescription('招商银行协议扣款前发送短信');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(Input $input, Output $output)
|
|
||||||
{
|
|
||||||
$redis = RedisService::getRedisInstance();
|
|
||||||
Sign::where(['sign_status' => Sign::SIGN_STATUS_SUCCESS])->field('*')->chunk(50, function (Collection $signCollection) use (&$output, $redis) {
|
|
||||||
foreach ($signCollection as $collection) {
|
|
||||||
// 查询是否已经生成过订单
|
|
||||||
$order = Order::getPaidOrderByAgreementId($collection->m_agreement_id);
|
|
||||||
if ($order->isEmpty() || empty($collection->agree_recharge_time) || $order->order_status != Order::STATUS_RECHARGE_SUCCESS) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 使用redis,判断消息短时间,不会重复发送
|
|
||||||
$cacheKeys = BusinessCacheKey::AGREEMENT_PAY_SEND_SMS;
|
|
||||||
$cacheKey = $cacheKeys['key'] . "_" . $collection->mobile;
|
|
||||||
$key = $redis->get($cacheKey);
|
|
||||||
if (!empty($key)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 该协议号扣款订单次数
|
|
||||||
$orderCount = Order::getCountByAgreementId($collection->m_agreement_id);
|
|
||||||
if ($orderCount == 12) { // 1年扣款12次
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$oneYearAgo = strtotime("-1 year", time());
|
|
||||||
if ($oneYearAgo > strtotime($collection->create_time)) { // 签约时间超过一年
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$currentTimestamp = strtotime(date('Y-m-d'));
|
|
||||||
$agreeRechargeTime = $collection->agree_recharge_time;
|
|
||||||
$day = env('cmb.agree_pay_day');
|
|
||||||
if ($currentTimestamp != $agreeRechargeTime + ($day - 1) * 24 * 60 * 60) { //未到发送短信的时间,只发送刚满30天的记录,超过30天不再发送
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (empty($collection->mobile)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->count += 1;
|
|
||||||
// 开始发送扣款短信
|
|
||||||
$res = AliSms::sendSms(['phone_numbers' => $collection->mobile], 3);
|
|
||||||
$redis->set($cacheKey, true, 'ex', $cacheKeys['ttl']);
|
|
||||||
if ($res['code'] == 200) {
|
|
||||||
$this->successCount += 1;
|
|
||||||
$output->writeln("短信发送受理成功");
|
|
||||||
} else {
|
|
||||||
$this->failedCount += 1;
|
|
||||||
$output->writeln("手机号" . $collection->mobile . "发送短信失败:" . $res['message']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Log::info(sprintf("扣款前发送短信执行情况:执行成功,累计 %s, 受理成功 %s, 失败 %s", $this->count, $this->successCount, $this->failedCount));
|
|
||||||
$output->writeln(sprintf("执行成功,累计 %s, 受理成功 %s, 失败 %s", $this->count, $this->successCount, $this->failedCount));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace app\cmd;
|
|
||||||
|
|
||||||
use app\model\Order;
|
|
||||||
use app\model\Sign;
|
|
||||||
use app\service\AgreementService;
|
|
||||||
use think\Collection;
|
|
||||||
use think\console\Command;
|
|
||||||
use think\console\Input;
|
|
||||||
use think\console\Output;
|
|
||||||
use think\facade\Log;
|
|
||||||
|
|
||||||
class PayOrderRetry extends Command
|
|
||||||
{
|
|
||||||
protected int $count = 0;
|
|
||||||
protected int $successCount = 0;
|
|
||||||
protected int $failedCount = 0;
|
|
||||||
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
$this->setName('payOrderRetry')->setDescription('重试扣款失败的订单');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 所有失败订单每天重试一次,重试到订单创建时间的月底。如果还是失败就进行解约操作
|
|
||||||
* 每天11点执行
|
|
||||||
* @param Input $input
|
|
||||||
* @param Output $output
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function execute(Input $input, Output $output)
|
|
||||||
{
|
|
||||||
// 本月内的支付失败订单
|
|
||||||
// 获取本月的开始时间
|
|
||||||
$startOfMonth = new \DateTime('first day of this month 00:00:00');
|
|
||||||
$startOfMonthFormatted = $startOfMonth->format('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// 获取本月的结束时间
|
|
||||||
$endOfMonth = new \DateTime('last day of this month 23:59:59');
|
|
||||||
$endOfMonthFormatted = $endOfMonth->format('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
Order::where(['pay_status' => Order::PAY_STATUS_FAIL])->whereBetweenTime('create_time', strtotime($startOfMonthFormatted), strtotime($endOfMonthFormatted))
|
|
||||||
->where(['is_retry' => Order::RETRY_STATUS_NO])
|
|
||||||
->field('id,order_number,agreement_id,user_id')->chunk(100, function (Collection $orderCollection) use (&$output) {
|
|
||||||
// 拉取支付失败的订单
|
|
||||||
foreach ($orderCollection as $order) {
|
|
||||||
// 查询签约状态是否取消
|
|
||||||
$signInfo = Sign::getByAgreementId($order->agreement_id);
|
|
||||||
if ($signInfo->isEmpty() || $signInfo->sign_status != Order::STATUS_SIGNED) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$res = AgreementService::RetryPayOrder($order->order_number, $signInfo->agreement_id);
|
|
||||||
if ($res['respCode'] == 1000) {
|
|
||||||
$this->successCount += 1;
|
|
||||||
$output->writeln("受理成功,等待支付通知");
|
|
||||||
} else {
|
|
||||||
$this->failedCount += 1;
|
|
||||||
$output->writeln("用户" . $order->user_id . "扣款失败:" . $res['respMsg']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Log::info(sprintf("重试扣款失败的job执行情况:执行成功,累计 %s, 受理成功 %s, 失败 %s", $this->count, $this->successCount, $this->failedCount));
|
|
||||||
$output->writeln(sprintf("重试扣款失败的订单执行成功,累计 %s, 受理成功 %s, 失败 %s", $this->count, $this->successCount, $this->failedCount));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -34,9 +34,4 @@ class BusinessCacheKey
|
||||||
'ttl' => self::MINUTE * 5
|
'ttl' => self::MINUTE * 5
|
||||||
];
|
];
|
||||||
|
|
||||||
const AGREEMENT_PAY_SEND_SMS = [
|
|
||||||
'key' => 'agreement_pay_send_sms',
|
|
||||||
'ttl' => self::DAY * 2
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace app\front;
|
namespace app\front;
|
||||||
|
|
||||||
|
use app\config\ResponseCode;
|
||||||
use app\service\CmbService;
|
use app\service\CmbService;
|
||||||
use app\service\OrderService;
|
use app\service\OrderService;
|
||||||
use app\service\RechargeService;
|
use app\service\RechargeService;
|
||||||
|
@ -11,14 +12,9 @@ class Order extends Base
|
||||||
{
|
{
|
||||||
public function list(Request $request): \think\Response
|
public function list(Request $request): \think\Response
|
||||||
{
|
{
|
||||||
if (empty($request->user_id)) {
|
|
||||||
return responseOk();
|
|
||||||
}
|
|
||||||
$params['user_id'] = $request->user_id;
|
$params['user_id'] = $request->user_id;
|
||||||
$params['is_retry'] = \app\model\Order::RETRY_STATUS_NO;
|
|
||||||
return responseOk(app()->make(OrderService::class)->list($params));
|
return responseOk(app()->make(OrderService::class)->list($params));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单退订
|
* 订单退订
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
@ -40,7 +36,7 @@ class Order extends Base
|
||||||
{
|
{
|
||||||
$params = $request->post();
|
$params = $request->post();
|
||||||
$res = (new RechargeService())->rechargeNotify($params);
|
$res = (new RechargeService())->rechargeNotify($params);
|
||||||
echo $res;
|
echo $res;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,6 @@ class Order extends BaseModel
|
||||||
const REFUND_STATUS_WAIT = 1;
|
const REFUND_STATUS_WAIT = 1;
|
||||||
const REFUND_STATUS_SUCCESS = 2;
|
const REFUND_STATUS_SUCCESS = 2;
|
||||||
const REFUND_STATUS_FAIL = 3;
|
const REFUND_STATUS_FAIL = 3;
|
||||||
// 重试状态
|
|
||||||
const RETRY_STATUS_NO = 0; // 未重试
|
|
||||||
const RETRY_STATUS_YES = 1; // 已重试
|
|
||||||
|
|
||||||
const STATUS_TEXT = [
|
const STATUS_TEXT = [
|
||||||
self::STATUS_WAIT_SIGN => '待签约',
|
self::STATUS_WAIT_SIGN => '待签约',
|
||||||
|
|
|
@ -64,13 +64,13 @@ class AgreementService extends BaseService
|
||||||
$order->create_time = time();
|
$order->create_time = time();
|
||||||
$order->save();
|
$order->save();
|
||||||
} else {
|
} else {
|
||||||
Sign::create([
|
Sign::create(
|
||||||
'user_id' => $userId,
|
['user_id' => $userId,
|
||||||
'open_id' => $user->open_id,
|
'open_id' => $user->open_id,
|
||||||
'mobile' => $account,
|
'mobile' => $account,
|
||||||
'request_serial' => $params['requestSerial'],
|
'request_serial' => $params['requestSerial'],
|
||||||
'm_agreement_id' => $params['mAgreementId']
|
'm_agreement_id' => $params['mAgreementId']]
|
||||||
]);
|
);
|
||||||
// 创建订单
|
// 创建订单
|
||||||
$data = [
|
$data = [
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
|
@ -85,7 +85,7 @@ class AgreementService extends BaseService
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
throw new \LogicException($e->getMessage());
|
throw new \LogicException($e->getMessage());
|
||||||
}
|
}
|
||||||
return CmbLifeUtils::genProtocol($funcName, $params);
|
return CmbLifeUtils::genProtocol($funcName, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,68 +216,6 @@ class AgreementService extends BaseService
|
||||||
return CmbHttpUtils::doPost($funcName, $requestParams);
|
return CmbHttpUtils::doPost($funcName, $requestParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 扣款失败,重试
|
|
||||||
*
|
|
||||||
* @param string $orderNumber
|
|
||||||
* @param string $agreementId
|
|
||||||
* @return array|mixed|string
|
|
||||||
*/
|
|
||||||
public static function RetryPayOrder(string $orderNumber, string $agreementId)
|
|
||||||
{
|
|
||||||
// 判断订单状态是否正确
|
|
||||||
$order = Order::getByOrderNumber($orderNumber);
|
|
||||||
if ($order->isEmpty() || $order->pay_status != Order::PAY_STATUS_FAIL || $order->is_retry == Order::RETRY_STATUS_YES) {
|
|
||||||
return ['respCode' => 1000, 'respMsg' => '处理成功'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理订单再次扣款
|
|
||||||
// 创建新的订单
|
|
||||||
$productId = $order->product_id;
|
|
||||||
$product = Product::getBySupplierProductId($productId);
|
|
||||||
$newOrder = [
|
|
||||||
'user_id' => $order->user_id,
|
|
||||||
'order_number' => StringUtil::makeOrderNumber(),
|
|
||||||
'account' => $order->account,
|
|
||||||
'type' => $order->type,
|
|
||||||
'product_id' => $order->product_id,
|
|
||||||
'price' => $order->price,
|
|
||||||
'bonus' => $order->bonus,
|
|
||||||
'agreement_id' => $order->agreement_id,
|
|
||||||
'order_status' => Order::STATUS_SIGNED
|
|
||||||
];
|
|
||||||
|
|
||||||
// 生成重试订单
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
|
||||||
// 创建新订单
|
|
||||||
Order::create($newOrder);
|
|
||||||
// 更新老订单
|
|
||||||
$order->is_retry = Order::RETRY_STATUS_YES;
|
|
||||||
$order->retry_order_num = $newOrder['order_number'];
|
|
||||||
$res = $order->save();
|
|
||||||
if (!$res) {
|
|
||||||
throw new \Exception("重试支付,更新老订单失败,订单号:" . $orderNumber);
|
|
||||||
}
|
|
||||||
Db::commit();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Db::rollback();
|
|
||||||
Log::error("Job:PayOrderRetry,错误信息:" . $e->getMessage());
|
|
||||||
return ['respCode' => 1001, 'respMsg' => $e->getMessage()];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 扣款参数
|
|
||||||
$requestParams = [
|
|
||||||
'agreementId' => $agreementId,
|
|
||||||
'billNo' => $newOrder['order_number'],
|
|
||||||
'amount' => $newOrder['price'] * 100,
|
|
||||||
'notifyUrl' => config('cmb.pay_notify_url'),
|
|
||||||
'productName' => $product['name']
|
|
||||||
];
|
|
||||||
$funcName = 'agreementPay';
|
|
||||||
return CmbHttpUtils::doPost($funcName, $requestParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 协议扣款回调处理
|
* 协议扣款回调处理
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
@ -314,10 +252,6 @@ class AgreementService extends BaseService
|
||||||
if ($encryptData['result'] == 2) {
|
if ($encryptData['result'] == 2) {
|
||||||
RechargeService::rechargeOrder($orderNumber); // 支付成功,到直连天下充值
|
RechargeService::rechargeOrder($orderNumber); // 支付成功,到直连天下充值
|
||||||
}
|
}
|
||||||
// 支付失败
|
|
||||||
if ($encryptData['result'] == 3 && BaseService::isLastDayOfMonth()) {
|
|
||||||
CmbService::releaseMerchant($order->agreement_id);
|
|
||||||
}
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return ['respCode' => 1000, 'respMsg' => '处理成功'];
|
return ['respCode' => 1000, 'respMsg' => '处理成功'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -412,7 +346,6 @@ class AgreementService extends BaseService
|
||||||
}
|
}
|
||||||
return ['success' => true];
|
return ['success' => true];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解约发送验证码
|
* 解约发送验证码
|
||||||
* @throws BusinessException
|
* @throws BusinessException
|
||||||
|
@ -437,7 +370,6 @@ class AgreementService extends BaseService
|
||||||
$user = User::getUserById($userId);
|
$user = User::getUserById($userId);
|
||||||
return ['mobile' => $user->mobile];
|
return ['mobile' => $user->mobile];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否能兑换
|
* 判断是否能兑换
|
||||||
* @param array $params
|
* @param array $params
|
||||||
|
@ -445,7 +377,7 @@ class AgreementService extends BaseService
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function getExchangeStatus(array $params): array
|
public static function getExchangeStatus(array $params): array
|
||||||
{
|
{
|
||||||
$isCanAgree = self::checkCanAgree($params['user_id'], '');
|
$isCanAgree = self::checkCanAgree($params['user_id'], '');
|
||||||
return ['is_exchange' => $isCanAgree['success']];
|
return ['is_exchange' => $isCanAgree['success']];
|
||||||
|
|
|
@ -44,14 +44,14 @@ class BaseService
|
||||||
$file = $data['file'];
|
$file = $data['file'];
|
||||||
$basePath = config('filesystem.disks.public.root');
|
$basePath = config('filesystem.disks.public.root');
|
||||||
validate(['file' => ['fileExt:jpg,png,jpeg,bmp,xlsx,xls,webp|fileSize:20*1024*1024']])->check($data);
|
validate(['file' => ['fileExt:jpg,png,jpeg,bmp,xlsx,xls,webp|fileSize:20*1024*1024']])->check($data);
|
||||||
$path = '/images/' . date('Y') . '/' . date('m') . '/' . date('d');
|
$path = '/images/'.date('Y').'/'.date('m').'/'.date('d');
|
||||||
$fullPath = $basePath . $path;
|
$fullPath = $basePath.$path;
|
||||||
if (!file_exists($fullPath)) {
|
if(!file_exists($fullPath)) {
|
||||||
mkdir($fullPath, 0777, true);
|
mkdir($fullPath,0777,true);
|
||||||
}
|
}
|
||||||
$imagePath = Filesystem::putFile($path, $file, 'md5');
|
$imagePath = Filesystem::putFile($path,$file,'md5');
|
||||||
$imagePath = str_replace('\\', '/', $imagePath);
|
$imagePath = str_replace('\\','/',$imagePath);
|
||||||
return ['image_path' => config('filesystem.disks.public.url') . $imagePath];
|
return ['image_path' =>config('filesystem.disks.public.url').$imagePath ];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __call($name, $arguments)
|
public function __call($name, $arguments)
|
||||||
|
@ -59,14 +59,4 @@ class BaseService
|
||||||
//找不到方法,自动调用模型中基类方法
|
//找不到方法,自动调用模型中基类方法
|
||||||
return call_user_func_array([$this->model, $name], $arguments);
|
return call_user_func_array([$this->model, $name], $arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isLastDayOfMonth()
|
|
||||||
{
|
|
||||||
$date = date('Y-m-d');
|
|
||||||
// 获取该月的最后一天
|
|
||||||
$lastDayOfMonth = date('Y-m-t', strtotime($date));
|
|
||||||
|
|
||||||
// 比较给定日期和该月的最后一天
|
|
||||||
return $date === $lastDayOfMonth;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -167,8 +167,7 @@ class CmbService extends BaseService
|
||||||
if ($res['result'] == 2) { // 扣款成功
|
if ($res['result'] == 2) { // 扣款成功
|
||||||
RechargeService::rechargeOrder($orderNumber);
|
RechargeService::rechargeOrder($orderNumber);
|
||||||
}
|
}
|
||||||
// 月底不进行重试,失败直接解约
|
if ($res['result'] == 3) { // 扣款失败 解约
|
||||||
if ($res['result'] == 3 && BaseService::isLastDayOfMonth()) { // 扣款失败 解约
|
|
||||||
self::releaseMerchant($order->agreement_id);
|
self::releaseMerchant($order->agreement_id);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -25,7 +25,7 @@ class OrderService extends BaseService
|
||||||
|
|
||||||
public function list($params)
|
public function list($params)
|
||||||
{
|
{
|
||||||
return $this->model->searchPages(['order_number', 'type', 'status', 'create_at', 'user_id', 'is_retry'], $params)->toArray();
|
return $this->model->searchPages(['order_number', 'type', 'status', 'create_at', 'user_id'], $params)->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,9 +33,9 @@ class OrderService extends BaseService
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
*/
|
*/
|
||||||
public function getMonthSale(): array
|
public function getMonthSale(): array
|
||||||
{
|
{
|
||||||
$count = $this->model->getCountLastMonth();
|
$count = $this->model->getCountLastMonth();
|
||||||
return ['count' => $count];
|
return ['count' => $count];
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,8 +34,6 @@ class AliSms
|
||||||
$template = env('alisms.template_sms_code');
|
$template = env('alisms.template_sms_code');
|
||||||
if($type == 2) {
|
if($type == 2) {
|
||||||
$template = env('alisms.template_issue_code');
|
$template = env('alisms.template_issue_code');
|
||||||
} else if ($type == 3) {
|
|
||||||
$template = env('alisms.template_agreement_pay_code');
|
|
||||||
}
|
}
|
||||||
$client = self::getInstance(env('alisms.app_id'),env('alisms.app_key'));
|
$client = self::getInstance(env('alisms.app_id'),env('alisms.app_key'));
|
||||||
$sms = new SendSmsRequest([]);
|
$sms = new SendSmsRequest([]);
|
||||||
|
|
|
@ -10,8 +10,6 @@ return [
|
||||||
'getPayOrder' => \app\cmd\GetPayOrder::class,
|
'getPayOrder' => \app\cmd\GetPayOrder::class,
|
||||||
'getRefundOrder' => \app\cmd\getRefundOrder::class,
|
'getRefundOrder' => \app\cmd\getRefundOrder::class,
|
||||||
'queryAgreeStatus' => \app\cmd\QueryAgreeStatus::class,
|
'queryAgreeStatus' => \app\cmd\QueryAgreeStatus::class,
|
||||||
'queryRechargeOrder' =>\app\cmd\QueryRechargeOrder::class,
|
'queryRechargeOrder' =>\app\cmd\QueryRechargeOrder::class
|
||||||
'payOrderRetry' =>\app\cmd\PayOrderRetry::class,
|
|
||||||
'agreementPaySendSms' =>\app\cmd\AgreementPaySendSms::class
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
location / {
|
location / {
|
||||||
index index.php index.html;
|
if (!-e $request_filename) {
|
||||||
if (!-e $request_filename) {
|
rewrite ^(.*)$ /index.php?s=/$1 last;
|
||||||
rewrite ^/index.php(.*)$ /index.php?s=$1 last; #必须在前面
|
break;
|
||||||
rewrite ^(.*)$ /index.php?s=$1 last;
|
}
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
|
|
@ -43,7 +43,6 @@ if (env('is_test')) {
|
||||||
|
|
||||||
Route::post('/front/loginSendSms', 'app\front\Login@loginSendSms')->validate(\app\validate\front\LoginValidate::class, 'sendSms')->middleware(\app\middleware\CorsMiddleware::class);
|
Route::post('/front/loginSendSms', 'app\front\Login@loginSendSms')->validate(\app\validate\front\LoginValidate::class, 'sendSms')->middleware(\app\middleware\CorsMiddleware::class);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Route::group('/api', function () {
|
Route::group('/api', function () {
|
||||||
Route::post('/front/login', 'app\admin\Login@login')->validate(\app\validate\admin\LoginValidate::class);
|
Route::post('/front/login', 'app\admin\Login@login')->validate(\app\validate\admin\LoginValidate::class);
|
||||||
Route::group('/front', function () {
|
Route::group('/front', function () {
|
||||||
|
|
Loading…
Reference in New Issue