|
@@ -3,6 +3,7 @@
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
+use app\common\model\Message;
|
|
|
use think\Db;
|
|
|
use app\common\library\Sms as Smslib;
|
|
|
/**
|
|
@@ -430,6 +431,7 @@ class Dispatch extends Common
|
|
|
$data["createtime"] = time();
|
|
|
$res = $orderModel->insertGetId($data);
|
|
|
if($res) {
|
|
|
+ \app\common\model\Message::addMessage($authInfo["user_id"],"派单通知","您的技能:".$skillInfo["name"]."有人下单啦,请注意查看!");
|
|
|
Db::commit();
|
|
|
$this->success('订单创建成功!',["order_no"=>$out_trade_no]);
|
|
|
} else {
|
|
@@ -554,7 +556,7 @@ class Dispatch extends Common
|
|
|
$reciveuserInfo = $userModel->where(["id"=>$orderInfo["recive_id"]])->find();
|
|
|
//Smslib::notice($reciveuserInfo->mobile, $orderInfo["skill_name"],"有人接单啦",'orderNotice');
|
|
|
// 系统消息通知
|
|
|
- \app\common\model\Message::addMessage($orderInfo["recive_id"],"派单通知","您的派单,技能:".$orderInfo["skill_name"]."有人接单啦,请登录伴声app查看!");
|
|
|
+ \app\common\model\Message::addMessage($orderInfo["recive_id"],"派单通知","您的派单,技能:".$orderInfo["skill_name"]."有人接单啦,请注意查看!");
|
|
|
|
|
|
$this->success('支付成功!');
|
|
|
} else {
|
|
@@ -639,7 +641,7 @@ class Dispatch extends Common
|
|
|
//$reciveuserInfo = $userModel->where(["id"=>$orderInfo["user_id"]])->find();
|
|
|
//Smslib::notice($reciveuserInfo->mobile, $orderInfo["skill_name"],"被拒绝接单",'orderNotice');
|
|
|
// 系统消息通知
|
|
|
- \app\common\model\Message::addMessage($orderInfo["user_id"],"派单通知","您的订单,技能:".$orderInfo["skill_name"]."已被拒绝接单,请登录伴声app查看!");
|
|
|
+ \app\common\model\Message::addMessage($orderInfo["user_id"],"派单通知","您的订单,技能:".$orderInfo["skill_name"]."已被拒绝接单,请注意查看!");
|
|
|
|
|
|
$this->success('订单完成。');
|
|
|
} else {
|
|
@@ -702,7 +704,7 @@ class Dispatch extends Common
|
|
|
//Smslib::send($reciveuserInfo->mobile, $orderInfo["skill_name"], "顺利完成啦!",'orderNotice');
|
|
|
|
|
|
// 系统消息通知
|
|
|
- \app\common\model\Message::addMessage($orderInfo["recive_id"],"派单通知","您的派单,技能:".$orderInfo["skill_name"]." 完成啦!,请登录GG语音app查看!");
|
|
|
+ \app\common\model\Message::addMessage($orderInfo["recive_id"],"派单通知","您的派单,技能:".$orderInfo["skill_name"]." 完成啦!,请注意查看!");
|
|
|
|
|
|
$this->success('恭喜!订单完成。');
|
|
|
} else {
|
|
@@ -718,6 +720,56 @@ class Dispatch extends Common
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
+ }if($status == -2) { // 取消订单
|
|
|
+ if($orderInfo["status"] != 1) {
|
|
|
+ $this->error(__('当前订单状态不支持拒绝订单!'),[],104);
|
|
|
+ }
|
|
|
+ // 完成订单操作需要更新余额记录
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $userModel = new \app\common\model\User();
|
|
|
+ $money = $orderInfo["price"] * $orderInfo["num"];
|
|
|
+ // 解冻用户余额
|
|
|
+ $where = [];
|
|
|
+ $where["id"] = $this->auth->id;
|
|
|
+ $userInfo = $userModel->where($where)->find();
|
|
|
+ if($userInfo["frozen"] - $money < 0) {
|
|
|
+ $this->error(__('账户资金异常,请联系管理员!'),[],105);
|
|
|
+ }
|
|
|
+ $res1 = $userModel->where($where)->setDec("frozen",$money);
|
|
|
+ $res2 = $userModel->where($where)->setInc("jewel",$money);
|
|
|
+ // 添加用户余额变动记录
|
|
|
+ $userjewellogModel = new \app\common\model\UserJewelLog();
|
|
|
+ $res3 = $userjewellogModel->addUserJewelLog($orderInfo["recive_id"], $money, "+", $userInfo["jewel"], "拒绝订单返还余额", 7);
|
|
|
+ // 更新订单状态
|
|
|
+ $data = [];
|
|
|
+ $data["status"] = $status;
|
|
|
+ $where = [];
|
|
|
+ $where["order_no"] = $order_no;
|
|
|
+ $res4 = $orderModel->update($data,$where);
|
|
|
+
|
|
|
+ if($res1 && $res2 && $res3 && $res4) {
|
|
|
+ Db::commit();
|
|
|
+ // 短信通知
|
|
|
+ //$reciveuserInfo = $userModel->where(["id"=>$orderInfo["user_id"]])->find();
|
|
|
+ //Smslib::notice($reciveuserInfo->mobile, $orderInfo["skill_name"],"被拒绝接单",'orderNotice');
|
|
|
+ // 系统消息通知
|
|
|
+ \app\common\model\Message::addMessage($orderInfo["recive_id"],"派单通知","您的订单,技能:".$orderInfo["skill_name"]."已被取消,请登录查看!");
|
|
|
+
|
|
|
+ $this->success('订单取消成功。');
|
|
|
+ } else {
|
|
|
+ $this->error(__('订单更新失败!请稍后重试'));
|
|
|
+ }
|
|
|
+ }catch (ValidateException $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ } catch (PDOException $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
} else {
|
|
|
$data = [];
|
|
|
$data["status"] = $status;
|
|
@@ -725,6 +777,9 @@ class Dispatch extends Common
|
|
|
$where["order_no"] = $order_no;
|
|
|
$res = $orderModel->update($data,$where);
|
|
|
if($res) {
|
|
|
+ if ($status == 2) {//接单发
|
|
|
+ \app\common\model\Message::addMessage($orderInfo['user_id'],"订单单通知","您的订单:".$order_no."已被接单,请登录查看!");
|
|
|
+ }
|
|
|
$this->success('更新成功!');
|
|
|
} else {
|
|
|
$this->error(__('订单创建失败!'));
|