weizong song 5 years ago
parent d61993232c
commit 3d2013df01

@ -114,28 +114,12 @@ class OrdersController extends CommonController
public function getBadges()
{
$orders_count = [];
$orders_count["unconfirmed"] = (new Orders())->where("status", Orders::STATUS_UNCONFIRMED)
->ofProject($this->manager->projects->pluck("id")->toArray())->count();
$orders_count["unassigned"] = (new Orders())->ofManager($this->manager->id)->where("status", Orders::STATUS_UNASSIGNED)->count();
$orders_count["ongoing"] = (new Orders())->ofManager($this->manager->id)->where("status", Orders::STATUS_ONGOING)->count();
$orders_count["finished"] = (new Orders())->ofManager($this->manager->id)->where("status", Orders::STATUS_FINISHED)->count();
//todo:改造为从通知系统获取未读数量
$approval_count = (new Approval())->where("status", Approval::STATUS_HANDLING);
switch ($this->manager->type) {
case "teacher":
$approval_count = $approval_count->where("created_by", $this->manager->id)->count();
break;
case "manager":
$project_ids = $this->manager->managerProjects->pluck("project_id")->toArray();
$approval_count = $approval_count->whereIn("project_id", $project_ids)->count();
break;
default:
$approval_count = 0;
break;
}
$orders_count["unconfirmed"] = 0;
$orders_count["unassigned"] = 0;
$orders_count["ongoing"] = 0;
$orders_count["finished"] = 0;
return response()->json(compact("orders_count", "approval_count"));
return response()->json(compact("orders_count"));
}
/**

@ -23,7 +23,6 @@ class WxMicroPay extends WxPayCommon
$this->setParameter("body", "充值{$recharge->money}元");
$this->setParameter("total_fee", $recharge->money * 100);
$this->setParameter("auth_code", request()->auth_code);
\Log::info($this->parameters);
if (!$this->parameters["out_trade_no"]) {
throw new Exception("缺少必填参数out_trade_no");
@ -44,16 +43,42 @@ class WxMicroPay extends WxPayCommon
//判断接口是否返回成功
if (!array_key_exists("return_code", $result) || !array_key_exists("result_code", $result)) {
throw new Exception("接口调用失败");
throw new Exception("接口调用失败!");
}
if ($result["return_code"] == "SUCCESS" && $result["result_code"] == "FAIL" && $result["err_code"] != "USERPAYING" && $result["err_code"] != "SYSTEMERROR") {
throw new Exception("支付失败!");
}
//
return true;
} catch (Exception $exception) {
return $exception;
}
//查询支付结果
$out_trade_no = $this->parameters["out_trade_no"];
$queryTimes = 10;
while ($queryTimes > 0) {
$succResult = 0;
$queryResult = $this->query($out_trade_no, $succResult);
//如果需要等待1s后继续
if ($succResult == 2) {
sleep(2);
continue;
} else if ($succResult == 1) {//查询成功
event();
return $queryResult;
} else {//订单交易失败
break;
}
}
//4、次确认失败则撤销订单
if (!$this->cancel($out_trade_no)) {
throw new WxpayException("撤销单失败!");
}
return true;
//取订单号
$out_trade_no = $microPayInput->GetOut_trade_no();

@ -42,11 +42,6 @@ class WxPayCommon
$this->parameters[$this->trimString($parameter)] = $this->trimString($parameterValue);
}
function checkParameters()
{
//检测必填参数
}
/**
* 生成接口参数xml
*/
@ -239,7 +234,7 @@ class WxPayCommon
* @return 成功时返回,其他抛异常
* @throws WxPayException
*/
protected function orderQuery($config, $inputObj, $timeOut = 6)
protected function orderQuery($inputObj, $timeOut = 6)
{
$url = "https://api.mch.weixin.qq.com/pay/orderquery";
//检测必填参数

Loading…
Cancel
Save