【类 型】:fix

【主	题】:在付款成功后 添加 取餐号
【描	述】:
	[原因]:在付款成功后 添加 取餐号
	[过程]:获取当天 已付款 已退款 总数+1 为付款成功后 的取餐号 ps:取餐号只在当天 递增
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
tk 2024-07-08 18:57:43 +08:00
parent 163bbe5894
commit 518d8350c3

View File

@ -103,16 +103,27 @@ class PayController extends PublicController
$result = Pay::wechat($this->config)->callback();
// 验证成功,处理业务逻辑
if ($result['resource']['ciphertext']['trade_state'] == 'SUCCESS') {
$shop_id = $result['resource']['ciphertext']['attach'];
$where['order_sn'] = $result['resource']['ciphertext']['out_trade_no']; // 获取订单号
$orderDb = D('order'); // 实例化订单模型
$data['main_status'] = '已付款'; // 更新订单状态为已支付
$data['paid_time'] = time(); //标记付款时间
$data['pay_sn'] = $result['resource']['ciphertext']['transaction_id']; // 支付订单号
// 更新订单
/*设置取餐号*/
// 获取当前时间的开始和结束时间戳
$startTime = strtotime('today');
$endTime = strtotime('tomorrow') - 1;
$whereFoodSn['main_status'] = array('in', array('已付款', '已退款'));
$whereFoodSn['order_time'] = array('between', array($startTime, $endTime));
$whereFoodSn['shop_id'] = $shop_id;
$orderCount = D('order')->where($whereFoodSn)->count();
// 新的food_sn为今天订单数加1
$data['food_sn'] = $orderCount + 1;
/*更新订单*/
$orderDb->where($where)->data($data)->save();
}
// 构建发布主题 并向地面终端提示刷新信息
$topic = 'refreshQuestList/' . $result['resource']['ciphertext']['attach'];
$topic = 'refreshQuestList/' . $shop_id;
$this->publish($topic, 1);
} catch (\Exception $e) {
// 捕获并记录可能的异常