【类 型】:refactor

【主	题】:修改订单状态
【描	述】:
	[原因]:不处理订单状态处于 已取消 未付款 交易关闭的情况
	[过程]:
	[影响]:
【结	束】

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

View File

@ -542,33 +542,38 @@ class PlaneController extends PublicController
echo json_encode(array('status' => 1, 'msg' => '访问成功', "questList" => $questList));
}
/**
* @description: 改变订单 quest字段 改变为接单状态
* @description: 改变订单状态或退款字段 不处理 已取消 未付款 交易关闭的订单
*/
public function questAss()
{
if ($this->tokenShop_id != C('powerId')) { //非总管理员
$where['shop_id'] = $this->tokenShop_id;
}
//前端提交数据校验
if ($_REQUEST['id'] && $_REQUEST['state'] && $_REQUEST['val']) {
$where['id'] = $_REQUEST['id'];
$orderDb = D('order');
if ($_REQUEST['state'] == 'status') {
$data['status'] = $_REQUEST['val']; //改变订单状态
} elseif ($_REQUEST['state'] == 'back') {
if ($_REQUEST['val'] == 'zero') {
$data['back'] = '0'; //改变退货状态
} else {
$data['back'] = '1'; //改变退货状态
}
}
if ($orderDb->where($where)->save($data)) {
echo json_encode(array('status' => 1, 'msg' => '订单修改成功'));
} else {
echo json_encode(array('status' => 0, 'msg' => '订单修改失败'));
$field = array('status');
$order = $orderDb->where($where)->field($field)->find();
//不处理订单状态处于 已取消 未付款 交易关闭的情况
if ($order['status'] == 'canceled' || $order['status'] == 'unpaid' || $order['status'] == 'closed') {
echo json_encode(array('status' => 0, 'msg' => '参数有误'));
exit();
}
} else {
echo json_encode(array('status' => 0, 'msg' => '参数有误'));
exit();
}
//操作数据库
if ($_REQUEST['state'] == 'status') {
$data['status'] = $_REQUEST['val']; //改变订单状态
} elseif ($_REQUEST['state'] == 'back') {
$data['back'] = $_REQUEST['val']; //改变订单状态
}
if ($orderDb->where($where)->save($data)) {
echo json_encode(array('status' => 1, 'msg' => '订单修改成功'));
} else {
echo json_encode(array('status' => 0, 'msg' => '订单修改失败'));
}
}
}