|
|
@@ -169,7 +169,7 @@ class Lave extends Api
|
|
|
// ['help_id', 0],
|
|
|
['plan_id', 0],
|
|
|
['from', 'weixin'],
|
|
|
- ['return_web','1']
|
|
|
+ ['return_web', '1']
|
|
|
], $request
|
|
|
);
|
|
|
@file_put_contents("quanju.txt", $where['from'] . "-来源\r\n", 8);
|
|
|
@@ -178,7 +178,7 @@ class Lave extends Api
|
|
|
}
|
|
|
$return_web = $where['return_web'];
|
|
|
unset($where['return_web']);
|
|
|
- $where['user_id']=$this->auth->getUserinfo()['id'];
|
|
|
+ $where['user_id'] = $this->auth->getUserinfo()['id'];
|
|
|
$where1 = $where;
|
|
|
unset($where1['from']);
|
|
|
$where1['order_id'] = LaveMonthModel::getNewOrderId();
|
|
|
@@ -198,12 +198,12 @@ class Lave extends Api
|
|
|
@file_put_contents("quanju.txt", $plan_id . "-签约模版编号\r\n", 8);
|
|
|
// unset($where1['plan_id']);
|
|
|
$where1['contract_code'] = WechatPlanRecord::getNewCode();
|
|
|
- if ($where['user_id']!=6779&&$where['user_id']!=12125){
|
|
|
+ if ($where['user_id'] != 6779 && $where['user_id'] != 12125) {
|
|
|
$order = LaveMonthModel::create($where1);
|
|
|
if (!$order) $this->error(LaveMonthModel::getErrorInfo());
|
|
|
$orderId = $order['order_id'];
|
|
|
$order['plan_id'] = $plan_id;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$orderId = $where1['order_id'];
|
|
|
}
|
|
|
$where1['contract_display_account'] = $where1['name'];
|
|
|
@@ -211,7 +211,7 @@ class Lave extends Api
|
|
|
|
|
|
$info = compact('orderId');
|
|
|
if ($orderId) {
|
|
|
- if ($where['user_id']!=6779&&$where['user_id']!=12125){
|
|
|
+ if ($where['user_id'] != 6779 && $where['user_id'] != 12125) {
|
|
|
$orderInfo = LaveMonthModel::where('order_id', $orderId)->find();
|
|
|
if (!$orderInfo || !isset($orderInfo['paid'])) {
|
|
|
$this->error('支付订单不存在!');
|
|
|
@@ -244,7 +244,7 @@ class Lave extends Api
|
|
|
} else if ($where['from'] == 'weixinh5') {
|
|
|
$jsConfig = LaveRepository::h5PaySign($this->cid, $orderId, $plan_record);
|
|
|
} else {
|
|
|
- $jsConfig = LaveRepository::wxPaySign($this->cid, $orderId, $plan_record,$return_web);
|
|
|
+ $jsConfig = LaveRepository::wxPaySign($this->cid, $orderId, $plan_record, $return_web);
|
|
|
}
|
|
|
} catch (\Exception $e) {
|
|
|
return $this->error($e->getMessage());
|
|
|
@@ -291,7 +291,7 @@ class Lave extends Api
|
|
|
|
|
|
if ($today == $day - 1 || $tf) { //再确定是不是今天是不是签约日期的前一天
|
|
|
// var_dump(789456132);die();
|
|
|
- @file_put_contents("quanju.txt", json_encode($v)."-月捐数据\r\n", 8);
|
|
|
+ @file_put_contents("quanju.txt", json_encode($v) . "-月捐数据\r\n", 8);
|
|
|
$cid = $v['cid'];
|
|
|
$mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
|
|
|
$where1['cid'] = $cid;
|
|
|
@@ -319,7 +319,7 @@ class Lave extends Api
|
|
|
// }
|
|
|
// var_dump(988745613);die();
|
|
|
$rs = WechatService::papPayApply($mch_id, $where1['order_id'], $where1['amount'], "lave", '月捐款', 'PAP', [], $cid, $v['contract_id'], $where1['order_name'], $where1['nonce_str']);
|
|
|
- @file_put_contents("quanju.txt", json_encode($rs)."-月捐汇报\r\n", 8);
|
|
|
+ @file_put_contents("quanju.txt", json_encode($rs) . "-月捐汇报\r\n", 8);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -327,52 +327,57 @@ class Lave extends Api
|
|
|
$this->success('扣款完成');
|
|
|
// }
|
|
|
}
|
|
|
+
|
|
|
// 申请进行第一次的扣款
|
|
|
public static function paySignPap($contract_code)
|
|
|
{
|
|
|
- @file_put_contents("quanju3.txt", $contract_code."测试申请扣款-\r\n", 8);
|
|
|
+ @file_put_contents("quanju3.txt", $contract_code . "测试申请扣款-\r\n", 8);
|
|
|
// die();
|
|
|
|
|
|
$plan = WechatPlanRecord::where('contract_code', $contract_code)->find();
|
|
|
- if ($plan['uid']!=6779&&$plan['uid']!=12125){
|
|
|
+ if ($plan['uid'] != 6779 && $plan['uid'] != 12125) {
|
|
|
return false;
|
|
|
}
|
|
|
- if (!empty($plan)){
|
|
|
- $cid = $plan['cid'];
|
|
|
- $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
|
|
|
- $where1['cid'] = $cid;
|
|
|
- $where1['user_id'] = $plan['uid'];
|
|
|
- $where1['order_name'] = $plan['order_name'];
|
|
|
- $where1['order_id'] = LaveMonthModel::getNewOrderId();;
|
|
|
+ @file_put_contents("quanju3.txt", $plan['uid'] . "测试申请扣款uid-\r\n", 8);
|
|
|
+ if (!empty($plan)) {
|
|
|
+ $cid = $plan['cid'];
|
|
|
+ $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
|
|
|
+ $where1['cid'] = $cid;
|
|
|
+ $where1['user_id'] = $plan['uid'];
|
|
|
+ $where1['order_name'] = $plan['order_name'];
|
|
|
+ $where1['order_id'] = LaveMonthModel::getNewOrderId();;
|
|
|
|
|
|
// $where1['category_id']=$v['category_id'];
|
|
|
- $where1['amount'] = $plan['price'];
|
|
|
- $where1['name'] = $plan['contract_display_account'];
|
|
|
- $where1['contact'] = '';
|
|
|
- $where1['tel'] = $plan['tel'];
|
|
|
- $where1['address'] = '用户未填写联系地址';
|
|
|
- $where1['is_open'] = $plan['is_open'];
|
|
|
- $where1['is_ticket'] = '0';
|
|
|
- $where1['type'] = '0';
|
|
|
- $where1['record_id'] = $plan['id'];
|
|
|
- $where1['contract_code'] = $plan['contract_code'];
|
|
|
- $where1['plan_id'] = $plan['plan_id'];
|
|
|
-
|
|
|
- $where1['nonce_str'] = uniqid();
|
|
|
+ $where1['amount'] = $plan['price'];
|
|
|
+ $where1['name'] = $plan['contract_display_account'];
|
|
|
+ $where1['contact'] = '';
|
|
|
+ $where1['tel'] = $plan['tel'];
|
|
|
+ $where1['address'] = '用户未填写联系地址';
|
|
|
+ $where1['is_open'] = $plan['is_open'];
|
|
|
+ $where1['is_ticket'] = '0';
|
|
|
+ $where1['type'] = '0';
|
|
|
+ $where1['record_id'] = $plan['id'];
|
|
|
+ $where1['contract_code'] = $plan['contract_code'];
|
|
|
+ $where1['plan_id'] = $plan['plan_id'];
|
|
|
+
|
|
|
+ $where1['nonce_str'] = uniqid();
|
|
|
// $where1['help_id']='0';
|
|
|
// @file_put_contents("quanju.txt", json_encode($where1)."测试申请扣款-\r\n", 8);
|
|
|
- $order = LaveMonthModel::create($where1);
|
|
|
+ $order = LaveMonthModel::create($where1);
|
|
|
// }
|
|
|
+ @file_put_contents("quanju3.txt", $order . "测试申请扣款创建订单-\r\n", 8);
|
|
|
// var_dump(988745613);die();
|
|
|
- $rs = WechatService::papPayApply($mch_id, $where1['order_id'], $where1['amount'], "lave", '月捐款', 'PAP', [], $cid, $v['contract_id'], $where1['order_name'], $where1['nonce_str']);
|
|
|
- @file_put_contents("quanju.txt", json_encode($rs)."-月捐汇报\r\n", 8);
|
|
|
+ $rs = WechatService::papPayApply($mch_id, $where1['order_id'], $where1['amount'], "lave", '月捐款', 'PAP', [], $cid, $v['contract_id'], $where1['order_name'], $where1['nonce_str']);
|
|
|
+ @file_put_contents("quanju.txt", json_encode($rs) . "-月捐汇报\r\n", 8);
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
// 检查签约用户是否有符合签约月份数量的扣款记录
|
|
|
- public function check_pay_pap(){
|
|
|
+ public function check_pay_pap()
|
|
|
+ {
|
|
|
$list = WechatPlanRecord::where('is_signing', 0)->select(); //签约中
|
|
|
@file_put_contents("quanju2.txt", "补漏每月扣款-\r\n", 8);
|
|
|
foreach ($list as $k => $v) {
|
|
|
@@ -388,7 +393,7 @@ class Lave extends Api
|
|
|
// $monthsDiff = floor($monthsDiff);
|
|
|
|
|
|
// if ($monthsDiff > 0&&$monthsDiff > $count+1) { //相差月数大于月捐记录数量
|
|
|
- @file_put_contents("quanju2.txt", $v['contract_code']."签约协议号-\r\n", 8);
|
|
|
+ @file_put_contents("quanju2.txt", $v['contract_code'] . "签约协议号-\r\n", 8);
|
|
|
// @file_put_contents("quanju2.txt", $monthsDiff."相差月份-\r\n", 8);
|
|
|
// @file_put_contents("quanju2.txt", $count."统计次数-\r\n", 8);
|
|
|
// 查找上个月是否有扣款记录
|
|
|
@@ -396,8 +401,8 @@ class Lave extends Api
|
|
|
$currentTimestamp = time();
|
|
|
// 获取一个月前的时间戳
|
|
|
$last_month = strtotime("-1 month", $currentTimestamp);
|
|
|
- $count = LaveMonthModel::where('contract_code', $v['contract_code'])->where('createtime','>', $last_month)->count();
|
|
|
- if ($count == 0){
|
|
|
+ $count = LaveMonthModel::where('contract_code', $v['contract_code'])->where('createtime', '>', $last_month)->count();
|
|
|
+ if ($count == 0) {
|
|
|
@file_put_contents("quanju2.txt", "没有上个月的扣款记录-\r\n", 8);
|
|
|
|
|
|
|
|
|
@@ -424,7 +429,7 @@ class Lave extends Api
|
|
|
$order = LaveMonthModel::create($where1);
|
|
|
$rs = WechatService::papPayApply($mch_id, $where1['order_id'], $where1['amount'], "lave", '月捐款', 'PAP', [], $cid, $v['contract_id'], $where1['order_name'], $where1['nonce_str']);
|
|
|
// }
|
|
|
- @file_put_contents("quanju2.txt", json_encode($rs)."-补偿月捐汇报\r\n", 8);
|
|
|
+ @file_put_contents("quanju2.txt", json_encode($rs) . "-补偿月捐汇报\r\n", 8);
|
|
|
}
|
|
|
}
|
|
|
$this->success('获取成功');
|
|
|
@@ -488,7 +493,7 @@ class Lave extends Api
|
|
|
['cid', $this->cid],
|
|
|
], $request
|
|
|
);
|
|
|
- @file_put_contents("quanju.txt", $where['cid']."-cid是多少\r\n", 8);
|
|
|
+ @file_put_contents("quanju.txt", $where['cid'] . "-cid是多少\r\n", 8);
|
|
|
if (!$where['id']) $this->error('参数错误');
|
|
|
$this->success('获取成功', WechatPlan::read($where));
|
|
|
}
|
|
|
@@ -523,6 +528,7 @@ class Lave extends Api
|
|
|
);
|
|
|
$this->success('获取成功', WechatPlanRecord::record_info($where));
|
|
|
}
|
|
|
+
|
|
|
// 签约记录详情
|
|
|
public function query_sign_order(Request $request)
|
|
|
{
|
|
|
@@ -532,20 +538,22 @@ class Lave extends Api
|
|
|
['cid', 0],
|
|
|
], $request
|
|
|
);
|
|
|
- $this->success('获取成功', WechatService::querySignOrder($where['order_id'],$where['cid']));
|
|
|
+ $this->success('获取成功', WechatService::querySignOrder($where['order_id'], $where['cid']));
|
|
|
}
|
|
|
+
|
|
|
//
|
|
|
public function day_query_sign_order(Request $request)
|
|
|
{
|
|
|
// 改成搜索三天内的未支付订单
|
|
|
$threeDaysAgo = strtotime('-3 days');
|
|
|
@file_put_contents("quanju2.txt", $threeDaysAgo . "-三天前时间戳\r\n", 8);
|
|
|
- $list = LaveMonth::where('paid',0)->where('cid', '>',1)->where('createtime','>', $threeDaysAgo)->select();
|
|
|
+ $list = LaveMonth::where('paid', 0)->where('cid', '>', 1)->where('createtime', '>', $threeDaysAgo)->select();
|
|
|
foreach ($list as $k => $v) {
|
|
|
- WechatService::querySignOrder($v['order_id'],$v['cid']);
|
|
|
+ WechatService::querySignOrder($v['order_id'], $v['cid']);
|
|
|
}
|
|
|
$this->success('修改成功!');
|
|
|
}
|
|
|
+
|
|
|
public function querycontract(Request $request)
|
|
|
{
|
|
|
$where = UtilService::getMore(
|
|
|
@@ -555,7 +563,7 @@ class Lave extends Api
|
|
|
], $request
|
|
|
);
|
|
|
$mch_id = Company::where('id', $where['cid'])->value('pay_weixin_mchid');
|
|
|
- $this->success('获取成功', WechatService::querycontract($mch_id,$where['contract_id'],'1.0',[],$where['cid']));
|
|
|
+ $this->success('获取成功', WechatService::querycontract($mch_id, $where['contract_id'], '1.0', [], $where['cid']));
|
|
|
}
|
|
|
}
|
|
|
|