Compare commits

...

2 Commits

  1. 2
      admin/src/app/views/customer_resources/customer_resources.vue
  2. 62
      niucloud/app/common.php
  3. 15
      niucloud/app/service/admin/order_table/OrderTableService.php
  4. 23
      niucloud/app/service/admin/pay/PayService.php
  5. 5
      niucloud/app/service/api/pay/PayService.php

2
admin/src/app/views/customer_resources/customer_resources.vue

@ -335,7 +335,7 @@
const addOrder = (row : any) => {
console.log(row);
editOrderTableDialog.value.setFormData(row)
editOrderTableDialog.value.setFormData({'resource_id' : row.id})
editOrderTableDialog.value.showDialog = true
}

62
niucloud/app/common.php

@ -1108,7 +1108,7 @@ function return_pay_config($campus_id, $order_id)
// 必填-商户公钥证书路径
'mch_public_cert_path' => $pay_config['apiclient_key'],
// 必填
'notify_url' => 'https://zh.hnhbty.cn/api/pay/qrcodenotify/order_id/' . $order_id,
'notify_url' => 'https://api.hnhbty.cn/api/pay/qrcodenotify/order_id/' . $order_id,
// 选填-公众号 的 app_id
'mp_app_id' => $vx_config['app_id'],
// 选填-小程序 的 app_id
@ -1362,3 +1362,63 @@ function get_staff_performance_total(int $staffId, string $performanceType = '',
}
}
function httpGet($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
curl_close($curl);
return $res;
}
function getAccessToken() {
$appId = 'wxaee2df4a4b31df05';
$appSecret = '06284bac15b25775293690765a6be4d9';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appId&secret=$appSecret";
$res = json_decode(httpGet($url));
$access_token = $res->access_token;
return $access_token;
}
//$touser 用户的openid
//$template_id 模板id
//$value 发送的 消息 数组
function sendMessage($touser,$template_id,$value) {
// 构建请求参数
$accessToken = getAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" .$accessToken;
if($template_id == 'ogmlvTC-Q2gLMBbRHAUKCSWpwyQIOrLBA30HyAKkEXg'){
$data = [
'touser' => $touser,
'template_id' => $template_id,
'data' => [
'thing3' => ['value' => $value['thing3'], 'color' => '#173177'], //课程名称
'time4' => ['value' => $value['time4'], 'color' => '#173177'],//课程周期 例子 2023年10月11日~2023年11月30日
'character_string7' => ['value' => $value['character_string7'], 'color' => '#173177'],//课程数量
'character_string9' => ['value' => $value['character_string9'], 'color' => '#173177'],//课程码 课程金额
'time5' => ['value' => $value['time5'], 'color' => '#173177']//上课时间
],
'miniprogram' => [
"appid" => "wxaee2df4a4b31df05",
"pagepath" => $value['pagepath']
]
];
}
// 发送 POST 请求
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
}

15
niucloud/app/service/admin/order_table/OrderTableService.php

@ -87,12 +87,15 @@ class OrderTableService extends BaseAdminService
public function add(array $data)
{
$personnel = new Personnel();
// $data['staff_id'] = $personnel->where(['sys_user_id' => $this->uid])->value("id");
// if(!$data['staff_id']){
// return fail("操作失败");
// }
$data['staff_id'] = $personnel->where(['sys_user_id' => $this->uid])->value("id");
if(!$data['staff_id']){
return fail("操作失败");
}
$cr = new CustomerResources();
$data['campus_id'] = $cr->where(['id' => $data['resource_id']])->value("campus");
$data['staff_id'] = 1;
// $data['staff_id'] = 1;
$res = $this->model->create($data);
return success("操作成功");
@ -107,6 +110,8 @@ class OrderTableService extends BaseAdminService
*/
public function edit(int $id, array $data)
{
$cr = new CustomerResources();
$data['campus_id'] = $cr->where(['id' => $data['resource_id']])->value("campus");
$this->model->where([['id', '=', $id]])->update($data);
return true;

23
niucloud/app/service/admin/pay/PayService.php

@ -14,6 +14,7 @@ namespace app\service\admin\pay;
use app\dict\common\ChannelDict;
use app\dict\pay\PayDict;
use app\dict\pay\PaySceneDict;
use app\model\campus_pay\CampusPay;
use app\model\customer_resources\CustomerResources;
use app\model\member\Member;
use app\model\order_table\OrderTable;
@ -245,12 +246,34 @@ class PayService extends BaseAdminService
$path = qrcode($url['code_url'],'',[],'upload/qrcode/pay/');
$order->where(['id' => $data['order_id']])->update(['payment_id' => $out_trade_no,'ipv3' => $config['mch_secret_key']]);
$payModel = new Pay();
$campus_pay = new CampusPay();
$campus_pay_info = $campus_pay->where(['campus_id' => $order_info['campus_id']])->findOrEmpty()->toArray();
$payModel->insert([
'main_id' => $resource_info['member_id'],
'from_main_id' => $resource_info['member_id'],
'out_trade_no' => $out_trade_no,
'trade_type' => '',
'trade_id' => $data['order_id'],
'trade_no' => $out_trade_no,
'body' => '扫码支付',
'money' => $order_info['order_amount'],
'status' => 0,
'create_time' => time(),
'type' => $order_info['payment_type'],
'mch_id' => $campus_pay_info['mchid'],
'main_type' => $order_info['payment_type'],
'channel' => '微信扫码支付'
]);
return ['qrcode_url' => getCurrentDomain().$path,'out_trade_no'=>$out_trade_no];
}
public function check_payment_status($data){
$order = new OrderTable();
$order_status = $order->where(['payment_id' => $data['out_trade_no']])->value("order_status");
return ['order_status'=>$order_status];
}
}

5
niucloud/app/service/api/pay/PayService.php

@ -180,6 +180,11 @@ class PayService extends BaseApiService
$order->where(['payment_id' => $info['out_trade_no']])->update(['order_status' => 'paid','payment_time' => date("Y-m-d H:i:s")]);
$payModel = new Pay();
$payModel->where(['trade_id' => $order_id])->update([
'status' => 2,
'pay_time' => time()
]);
event('Student', ['event_type' => 'add','data' => $order_info]);
}

Loading…
Cancel
Save