Compare commits
2 Commits
5b047f7bcd
...
88030c0580
Author | SHA1 | Date | |
---|---|---|---|
![]() |
88030c0580 | ||
![]() |
28ef6da15e |
@ -76,7 +76,7 @@ class PayController extends PublicController
|
|||||||
$orderParameter = [
|
$orderParameter = [
|
||||||
'out_trade_no' => $order['order_sn'],
|
'out_trade_no' => $order['order_sn'],
|
||||||
'description' => '餐品', //存商品名称吧 后期在做调整
|
'description' => '餐品', //存商品名称吧 后期在做调整
|
||||||
'attach' => strval($order['shop_id']), // 将 shop_id 转为字符串
|
'attach' => strval($order['shop_id']), // 将 shop_id 转为字符串 回调中用来发mqtt的主题
|
||||||
'amount' => [
|
'amount' => [
|
||||||
'total' => $order['total_price'] * 100, //单位:分
|
'total' => $order['total_price'] * 100, //单位:分
|
||||||
'currency' => 'CNY',
|
'currency' => 'CNY',
|
||||||
@ -100,7 +100,6 @@ class PayController extends PublicController
|
|||||||
{
|
{
|
||||||
// 实例化 Yansongda Pay
|
// 实例化 Yansongda Pay
|
||||||
$result = Pay::wechat($this->config)->callback();
|
$result = Pay::wechat($this->config)->callback();
|
||||||
$this->publish('refreshQuestList/2dc23dcfecc05fb1', $result['resource']['ciphertext']['attach']);
|
|
||||||
try {
|
try {
|
||||||
// 验证成功,处理业务逻辑
|
// 验证成功,处理业务逻辑
|
||||||
if ($result['resource']['ciphertext']['trade_state'] == 'SUCCESS') {
|
if ($result['resource']['ciphertext']['trade_state'] == 'SUCCESS') {
|
||||||
@ -113,8 +112,8 @@ class PayController extends PublicController
|
|||||||
$orderDb->where($where)->data($data)->save();
|
$orderDb->where($where)->data($data)->save();
|
||||||
}
|
}
|
||||||
// 构建发布主题 并向地面终端提示刷新信息
|
// 构建发布主题 并向地面终端提示刷新信息
|
||||||
// $topic = 'refreshQuestList/2dc23dcfecc05fb1';
|
$topic = 'refreshQuestList/' . $result['resource']['ciphertext']['attach'];
|
||||||
// $this->publish('refreshQuestList/2dc23dcfecc05fb1', $result['resource']['ciphertext']['description']);
|
$this->publish($topic, 1);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 捕获并记录可能的异常
|
// 捕获并记录可能的异常
|
||||||
error_log('支付回调处理错误:' . $e->getMessage());
|
error_log('支付回调处理错误:' . $e->getMessage());
|
||||||
|
@ -526,7 +526,7 @@ class PlaneController extends PublicController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @description: 改变订单状态或退款字段 不处理 已取消 未付款 交易关闭的订单
|
* @description: 只处理 主状态 为 已付款 的订单
|
||||||
*/
|
*/
|
||||||
public function questAss()
|
public function questAss()
|
||||||
{
|
{
|
||||||
@ -539,9 +539,8 @@ class PlaneController extends PublicController
|
|||||||
$orderDb = D('order');
|
$orderDb = D('order');
|
||||||
$field = array('status', 'back', 'openid');
|
$field = array('status', 'back', 'openid');
|
||||||
$order = $orderDb->where($where)->field($field)->find();
|
$order = $orderDb->where($where)->field($field)->find();
|
||||||
//不处理订单状态处于 已取消 未付款 交易关闭的情况
|
//只处理主状态已付款的订单 其他状态跳出
|
||||||
//不处理订单退款状态处于 主动退款 已退款 拒绝退款的状况
|
if ($order['main_status'] != '已付款') {
|
||||||
if ($order['status'] == 'canceled' || $order['status'] == 'unpaid' || $order['status'] == 'closed' || $order['back'] == 'actively' || $order['back'] == 'rejected' || $order['back'] == 'rejected' || $order['back'] == 'refunded') {
|
|
||||||
echo json_encode(array('status' => 0, 'msg' => '参数有误'));
|
echo json_encode(array('status' => 0, 'msg' => '参数有误'));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
@ -550,14 +549,16 @@ class PlaneController extends PublicController
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
//操作数据库
|
//操作数据库
|
||||||
if ($_REQUEST['state'] == 'status') {
|
if ($_REQUEST['state'] == 'main_status') {
|
||||||
$data['status'] = $_REQUEST['val']; //改变订单状态
|
$data['main_status'] = $_REQUEST['val'];
|
||||||
} elseif ($_REQUEST['state'] == 'back') {
|
} elseif ($_REQUEST['state'] == 'shipment_status') {
|
||||||
$data['back'] = $_REQUEST['val']; //改变订单状态
|
$data['shipment_status'] = $_REQUEST['val'];
|
||||||
|
} elseif ($_REQUEST['state'] == 'refund_status') {
|
||||||
|
$data['refund_status'] = $_REQUEST['val'];
|
||||||
}
|
}
|
||||||
if ($orderDb->where($where)->save($data)) { //修改数据
|
if ($orderDb->where($where)->save($data)) { //修改数据
|
||||||
$topicPrefix = makeTopicPrefix($order['openid']); //小程序端用户订阅主题的前缀 ps:订单对应的用户的openid算出来的
|
$topicPrefix = makeTopicPrefix($order['openid']); //小程序端用户订阅主题的前缀 ps:订单对应的用户的openid算出来的
|
||||||
// 提醒小程序端 刷新订单列表
|
// 提醒小程序端 刷新订单列表(mqtt)
|
||||||
$this->publish('refreshOrderList/' . $topicPrefix, 1);
|
$this->publish('refreshOrderList/' . $topicPrefix, 1);
|
||||||
echo json_encode(array('status' => 1, 'msg' => '订单修改成功'));
|
echo json_encode(array('status' => 1, 'msg' => '订单修改成功'));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user