feat: 增加订单推送功能,优化充值金额限制

This commit is contained in:
mkm 2024-06-27 16:38:00 +08:00
parent 28c94be5c9
commit 6238c1d594
2 changed files with 71 additions and 0 deletions

View File

@ -77,6 +77,9 @@ class StoreController extends BaseApiController
return $this->fail('验证码错误');
}
}
if($params['price']>10000){
return $this->fail('充值金额不能大于10000');
}
$find=User::where('mobile',$params['mobile'])->find();
if(!$find){
$params['create_uid']=$this->userId;

View File

@ -0,0 +1,68 @@
<?php
namespace app\queue\redis;
use app\common\enum\PayEnum;
use app\common\logic\PayNotifyLogic;
use app\common\model\retail\Cashierclass;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\system_store\SystemStore;
use app\common\model\user_recharge\UserRecharge;
use app\common\service\Curl;
use app\common\service\pay\PayService;
use app\common\service\PushService;
use Webman\RedisQueue\Consumer;
use support\exception\BusinessException;
use support\Log;
/**
* 企业微信订单推送队列消费
*/
class OrderWetchaPushSend implements Consumer
{
// 要消费的队列名
public $queue = 'order_wetcha_push_send';
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
public $connection = 'default';
// 消费
public function consume($data)
{
$url = getenv('WETCHA_PUSH');
if ($url) {
$order=$data['order'];
$order_id = $order['order_id'];
$total_price = $order['total_price'];
$pay_price = $order['pay_price'];
$pay_time = date('Y-m-d H:i:s', $order['pay_time']);
$phone = $order['user_phone'];
$pay_type = PayEnum::getPaySceneDesc($order['pay_type']);
$store_name = SystemStore::where('id', $order['store_id'])->value('name');
$cart_info=StoreOrderCartInfo::where('oid',$order['id'])->field('cart_info')->select();
$product_info="\r\n>商品信息:<font color=\"comment\">------------------</font>";
foreach($cart_info as $k=>$v['cart_info']){
$a=$v['cart_info']['cart_info']['name'].' 数量:'.$v['cart_info']['cart_info']['cart_num'].' 价格:'.$v['cart_info']['cart_info']['pay_price'].'元';
$product_info.="\r\n><font color=\"comment\">$a</font>";
}
$arr = ["msgtype" => "markdown", "markdown" => ["content" => "有新的订单请及时跟踪
>订单号:<font color=\"comment\">$order_id</font>
>门店信息:<font color=\"comment\">$store_name</font>"
.$product_info
."\r\n>下单时间:<font color=\"comment\">$pay_time</font>
>订单金额:<font color=\"comment\">$total_price</font>
>支付金额:<font color=\"comment\">$pay_price</font>
>支付方式:<font color=\"comment\">$pay_type</font>
>下单用户手机号:<font color=\"comment\">$phone</font>"]];
(new Curl())->postJson($url, json_encode($arr));
}
}
// 消费失败时
public function onConsumeFailure(\Throwable $exception, $package)
{
$package['max_attempts'] = 0;
Log::error('推送订单失败', ['order_id' => $package['data'], 'error' => $package['error']]);
return true;
}
}