|
@@ -23,9 +23,15 @@ class paylogic extends baselogic
|
|
|
{
|
|
|
$list = [
|
|
|
'getappointmentorderforxcx' => [
|
|
|
- ['name' => 'aid', 'title' => '申请单id', 'require' => true, 'type' => 'numeric'], //以元为单位
|
|
|
+ ['name' => 'aid', 'title' => '申请单id', 'require' => true, 'type' => 'numeric'],
|
|
|
['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
|
|
|
- ['name' => 'total_fee', 'title' => '支付费用', 'require' => true, 'type' => 'numeric'], //以元为单位
|
|
|
+ ['name' => 'total_fee', 'title' => '支付费用', 'require' => true, 'type' => 'numeric'], //以分为单位
|
|
|
+ ],
|
|
|
+ 'handlefrontorder' => [
|
|
|
+ ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
|
|
|
+ ['name' => 'orderstatus', 'title' => '订单状态', 'require' => true, 'type' => 'numeric'],
|
|
|
+ ['name' => 'outorderno', 'title' => '商户订单号', 'require' => true, 'type' => 'numeric'],
|
|
|
+ ['name' => 'ispay', 'title' => '已支付', 'require' => true, 'type' => 'numeric'],
|
|
|
],
|
|
|
];
|
|
|
return $list;
|
|
@@ -74,7 +80,7 @@ class paylogic extends baselogic
|
|
|
return backarr(1, "success", $orderinfo);
|
|
|
}
|
|
|
/**
|
|
|
- * 处理支付回调
|
|
|
+ * 处理后端支付回调
|
|
|
*
|
|
|
* @return void
|
|
|
* @author wj
|
|
@@ -127,22 +133,58 @@ class paylogic extends baselogic
|
|
|
switch ($ordertype) {
|
|
|
case 1:
|
|
|
$appointentid = $orderInfo['appointent_id'];
|
|
|
- $m_a = new appointmentmodel();
|
|
|
- $ainfo = $m_a->getInfo(['id' => $appointentid, 'ispay' => 0]);
|
|
|
- if (empty($ainfo)) {
|
|
|
- $msg = "申请单id:[" . $appointentid . "]不存在";
|
|
|
- throw new \Exception($msg);
|
|
|
+ if (1 === $ispay) {
|
|
|
+ $this->updateappointment($appointentid, $outorderno);
|
|
|
}
|
|
|
- $code = $appointentid . "|" . date("YmdHis");
|
|
|
- $aupdateData = [
|
|
|
- 'ispay' => 1,
|
|
|
- 'payorderno' => $outorderno,
|
|
|
- 'code' => $code,
|
|
|
- ];
|
|
|
- $row = $ainfo->updateinfo(['id' => $appointentid], $aupdateData);
|
|
|
- if (empty($row)) {
|
|
|
- $msg = "申请单id:[" . $appointentid . "]修改失败";
|
|
|
- throw new \Exception($msg);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ Log::info("commit");
|
|
|
+ return backarr(1, "处理完成", ['id' => $orderInfo['id']]);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ log::info("rollback");
|
|
|
+ return backarr(0, $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 处理前端支付回调
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2022-07-29
|
|
|
+ */
|
|
|
+ public function handlefrontorder($arr)
|
|
|
+ {
|
|
|
+ $result = $this->checkparam(__FUNCTION__, $arr);
|
|
|
+ if (1 != $result['status']) {
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ $data = $result['data'];
|
|
|
+ $openid = $data['openid'];
|
|
|
+ $ispay = $data['ispay'];
|
|
|
+ $orderstatus = $data['orderstatus'];
|
|
|
+ $outorderno = $data['outorderno'];
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ $m_po = new payordermodel;
|
|
|
+ $oupdateData = [
|
|
|
+ 'ispay' => $ispay,
|
|
|
+ 'orderstatus' => $orderstatus,
|
|
|
+ 'paytime' => date('Y-m-d H:i:s'),
|
|
|
+ 'is_front_back' => 1,
|
|
|
+ ];
|
|
|
+ $row = $m_po->updorederstatusbyorderno($outorderno, $openid, $oupdateData);
|
|
|
+ if (empty($row)) {
|
|
|
+ throw new \Exception("订单修改失败");
|
|
|
+ }
|
|
|
+ $orderInfo = $m_po->getorderinfobyoutorderno($outorderno);
|
|
|
+ $ordertype = $orderInfo['order_type'];
|
|
|
+ switch ($ordertype) {
|
|
|
+ case 1:
|
|
|
+ $appointentid = $orderInfo['appointent_id'];
|
|
|
+ if (1 === $ispay) {
|
|
|
+ $this->updateappointment($appointentid, $outorderno);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -155,4 +197,31 @@ class paylogic extends baselogic
|
|
|
return backarr(0, $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 改申请单
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2022-07-29
|
|
|
+ */
|
|
|
+ private function updateappointment($appointentid, $outorderno)
|
|
|
+ {
|
|
|
+ $m_a = new appointmentmodel();
|
|
|
+ $ainfo = $m_a->getInfo(['id' => $appointentid, 'ispay' => 0]);
|
|
|
+ if (empty($ainfo)) {
|
|
|
+ $msg = "申请单id:[" . $appointentid . "]不存在";
|
|
|
+ throw new \Exception($msg);
|
|
|
+ }
|
|
|
+ $code = $appointentid . "|" . date("YmdHis");
|
|
|
+ $aupdateData = [
|
|
|
+ 'ispay' => 1,
|
|
|
+ 'payorderno' => $outorderno,
|
|
|
+ 'code' => $code,
|
|
|
+ ];
|
|
|
+ $row = $ainfo->updateinfo(['id' => $appointentid], $aupdateData);
|
|
|
+ if (empty($row)) {
|
|
|
+ $msg = "申请单id:[" . $appointentid . "]修改失败";
|
|
|
+ throw new \Exception($msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|