|
|
@@ -260,6 +260,8 @@ class Lave extends Api
|
|
|
// 申请扣款
|
|
|
public function payPap(Request $request)
|
|
|
{
|
|
|
+ @file_put_contents("quanju.txt", "测试申请扣款-\r\n", 8);
|
|
|
+ die();
|
|
|
$list=WechatPlanRecord::where('is_signing',0)->select();
|
|
|
$cid=$this->cid;
|
|
|
|
|
|
@@ -269,32 +271,33 @@ class Lave extends Api
|
|
|
|
|
|
foreach ($list as $k => $v){
|
|
|
$cid=$v['cid'];
|
|
|
- $arr['mch_id'] =Company::where('id', $cid)->value('mch_id');
|
|
|
- $arr['out_trade_no']=LaveModel::getNewOrderId();
|
|
|
- $arr['total_fee'] = $v['price'];
|
|
|
+ if ($this->querySign($cid,$v['uid'],$v['plan_id'],$v['contract_code'])){
|
|
|
+ $arr['mch_id'] =Company::where('id', $cid)->value('mch_id');
|
|
|
+ $arr['out_trade_no']=LaveModel::getNewOrderId();
|
|
|
+ $arr['total_fee'] = $v['price'];
|
|
|
// $arr['trade_type'] = 'PAP';
|
|
|
- $arr['contract_id'] = Company::where('id', $cid)->value('contract_id');
|
|
|
+ $arr['contract_id'] = Company::where('id', $cid)->value('contract_id');
|
|
|
// $rs = WechatService::paymentOrder($openid, $orderInfo['order_id'], $orderInfo['amount'], "lave", $orderInfo['order_name'], '', 'JSAPI', [], $cid);
|
|
|
- $rs = WechatService::papPayApply($arr['out_trade_no'], $arr['total_fee'], "lave", '月捐款', 'PAP', [], $cid,$arr['mch_id'],$arr['contract_id']);
|
|
|
- $where1['cid']=$cid;
|
|
|
- $where1['user_id']=$this->auth->getUserinfo()['id'];
|
|
|
- $where1['order_name']='月捐款';
|
|
|
- $where1['category_id']=81;
|
|
|
- $where1['amount']=$arr['total_fee'];
|
|
|
- $where1['name']=$this->auth->getUserinfo()['username'];
|
|
|
- $where1['contact']='';
|
|
|
- $where1['tel']=$this->auth->getUserinfo()['mobile'];
|
|
|
- $where1['address']='用户未填写联系地址';
|
|
|
- $where1['is_open']=$v['is_open'];
|
|
|
- $where1['is_ticket']='0';
|
|
|
- $where1['type']='0';
|
|
|
- $where1['help_id']='0';
|
|
|
- $order = LaveModel::create($where1);
|
|
|
+ $rs = WechatService::papPayApply($arr['out_trade_no'], $arr['total_fee'], "lave", '月捐款', 'PAP', [], $cid,$arr['mch_id'],$arr['contract_id']);
|
|
|
+ $where1['cid']=$cid;
|
|
|
+ $where1['user_id']=$this->auth->getUserinfo()['id'];
|
|
|
+ $where1['order_name']='月捐款';
|
|
|
+ $where1['category_id']=81;
|
|
|
+ $where1['amount']=$arr['total_fee'];
|
|
|
+ $where1['name']=$this->auth->getUserinfo()['username'];
|
|
|
+ $where1['contact']='';
|
|
|
+ $where1['tel']=$this->auth->getUserinfo()['mobile'];
|
|
|
+ $where1['address']='用户未填写联系地址';
|
|
|
+ $where1['is_open']=$v['is_open'];
|
|
|
+ $where1['is_ticket']='0';
|
|
|
+ $where1['type']='0';
|
|
|
+ $where1['help_id']='0';
|
|
|
+ $order = LaveModel::create($where1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// 解除签约
|
|
|
public function deleteSign(Request $request){
|
|
|
- var_dump(123);die();
|
|
|
$where = UtilService::postMore(
|
|
|
[
|
|
|
['cid', $this->cid],
|
|
|
@@ -310,6 +313,7 @@ class Lave extends Api
|
|
|
$contract_code=$sign_info['contract_code'];
|
|
|
// $mch_id,$contract_code,$pan_id,$version='1.0',$options=[],$cid=0)
|
|
|
$rs=WechatService::deleteSign($mch_id,$contract_code,$plan_id,'1.0',[],$where['cid']);
|
|
|
+ @file_put_contents("quanju.txt", json_encode($rs)."-解除签约返回结果\r\n", 8);
|
|
|
if ($rs){
|
|
|
WechatPlanRecord::where('cid', $where['cid'])->where('uid', $where['user_id'])->where('is_signing',0)->update(['is_signing'=>1]);
|
|
|
$this->success('解除签约成功!');
|
|
|
@@ -317,6 +321,35 @@ class Lave extends Api
|
|
|
$this->error('解除签约失败!');
|
|
|
}
|
|
|
}
|
|
|
+// 查询签约状态
|
|
|
+ public function querySign(int $cid,int $uid,int $plan_id,string $contract_code)
|
|
|
+ {
|
|
|
+// $where = UtilService::postMore(
|
|
|
+// [
|
|
|
+// ['cid', $this->cid],
|
|
|
+// ['user_id', $this->auth->getUserinfo()['id']],
|
|
|
+// ], $request
|
|
|
+// );
|
|
|
+ $sign_info = WechatPlanRecord::where('cid', $cid)->where('uid', $uid)->where('is_signing', 1)->find();
|
|
|
+ if (!$sign_info) {
|
|
|
+ $this->error('未找到签约信息!');
|
|
|
+ }
|
|
|
+ $mch_id = Company::where('id', $cid)->value('mch_id');
|
|
|
+// $plan_id = $sign_info['plan_id'];
|
|
|
+// $contract_code = $sign_info['contract_code'];
|
|
|
+ $rs = WechatService::querySign($mch_id, $contract_code, $plan_id);
|
|
|
+ @file_put_contents("quanju.txt", json_encode($rs) . "-查询签约状态返回结果\r\n", 8);
|
|
|
+ if ($rs['return_code'] == 'SUCCESS') {
|
|
|
+ if ($rs['contract_state'] == 1) {
|
|
|
+ WechatPlanRecord::where('cid',$cid)->where('uid', $uid)->where('is_signing', 1)->update(['is_signing' => 0]);
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $this->error('查询签约状态失败!');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
?>
|