Lave.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <?php
  2. namespace app\api\controller;
  3. use app\admin\model\Company;
  4. use app\admin\model\LaveMonth;
  5. use app\admin\model\WechatPlan;
  6. use app\admin\model\WechatPlanRecord;
  7. use app\common\controller\Api;
  8. use app\common\model\{Category, Lave as LaveModel, User};
  9. use app\common\model\LaveMonth as LaveMonthModel;
  10. use liuniu\repositories\LaveRepository;
  11. use liuniu\UtilService;
  12. use liuniu\WechatService;
  13. use think\Request;
  14. class Lave extends Api
  15. {
  16. protected $noNeedLogin = ['*'];
  17. protected $noNeedRight = ['*'];
  18. public function lst(Request $request)
  19. {
  20. $where = UtilService::getMore(
  21. [
  22. ['page', 1],
  23. ['limit', 10],
  24. ['cid', $this->cid],
  25. ['paid', 1],
  26. ['category_id', 0],
  27. ['order', ''],
  28. ['key', ''],
  29. ], $request
  30. );
  31. $this->success('获取成功', LaveModel::lst($where));
  32. }
  33. public function ify()
  34. {
  35. $this->success('获取成功', Category::getCategoryArray('lave', null, $this->cid));
  36. }
  37. public function create(Request $request)
  38. {
  39. $where = UtilService::postMore(
  40. [
  41. ['cid', $this->cid],
  42. ['user_id', $this->auth->getUserinfo()['id']],
  43. ['order_name', ''],
  44. ['category_id', 0],
  45. ['amount', 0],
  46. ['name', ''],
  47. ['contact', ''],
  48. ['tel', 0],
  49. ['address', ''],
  50. ['is_open', '0'],
  51. ['is_ticket', '0'],
  52. ['pay_type', '0'],
  53. ['type', '0'],
  54. ['help_id', 0],
  55. ['from', 'weixin'],
  56. ], $request
  57. );
  58. $where1 = $where;
  59. unset($where1['from']);
  60. $where1['order_id'] = LaveModel::getNewOrderId();
  61. if (cache('lave_' . $where['user_id'])) $this->error('正在处理中');
  62. @file_put_contents("lave.txt", json_encode($where1));
  63. $order = LaveModel::create($where1);
  64. cache('lave_' . $where['user_id'], '1', 10);
  65. if (!$order) $this->error(LaveModel::getErrorInfo());
  66. $orderId = $order['order_id'];
  67. $info = compact('orderId');
  68. if ($orderId) {
  69. $orderInfo = LaveModel::where('order_id', $orderId)->find();
  70. if (!$orderInfo || !isset($orderInfo['paid'])) $this->error('支付订单不存在!');
  71. if ($orderInfo['paid']) $this->error('支付已支付!');
  72. try {
  73. if ($where['from'] == 'routine') {
  74. $jsConfig = LaveRepository::jsPay($this->cid, $orderId); //创建订单jspay
  75. } else if ($where['from'] == 'weixinh5') {
  76. $jsConfig = LaveRepository::h5Pay($this->cid, $orderId);
  77. } else {
  78. $jsConfig = LaveRepository::wxPay($this->cid, $orderId);
  79. }
  80. } catch (\Exception $e) {
  81. return $this->error($e->getMessage());
  82. }
  83. $info['jsConfig'] = $jsConfig;
  84. return $this->success('订单创建成功', $info);
  85. } else $this->error(LaveModel::getErrorInfo());
  86. }
  87. public function mylst(Request $request)
  88. {
  89. $where = UtilService::getMore(
  90. [
  91. ['page', 1],
  92. ['limit', 10],
  93. ['cid', $this->cid],
  94. ['user_id', $this->auth->getUserinfo()['id']],
  95. ['paid', -1],
  96. ['category_id', 0],
  97. ], $request
  98. );
  99. $this->success('获取成功', LaveModel::lst($where));
  100. }
  101. /**
  102. * 订单支付
  103. * @param Request $request
  104. * @return mixed
  105. */
  106. public function pay(Request $request)
  107. {
  108. list($uni, $paytype, $from) = UtilService::postMore([
  109. ['uni', ''],
  110. ['paytype', '0'],
  111. ['from', 'weixin']
  112. ], $request, true);
  113. if (!$uni) $this->error('参数错误!');
  114. $order = LaveModel::where('cid', $this->cid)->where('order_id', $uni)->find();
  115. if (!$order)
  116. $this->error('订单不存在!');
  117. if ($order['paid'])
  118. $this->error('该订单已支付!');
  119. $order['pay_type'] = $paytype; //重新支付选择支付方式
  120. switch ($order['pay_type']) {
  121. case '0':
  122. try {
  123. if ($from == 'routine') {
  124. $jsConfig = LaveRepository::jsPay($this->cid, $order); //订单列表发起支付
  125. } else if ($from == 'weixinh5') {
  126. $jsConfig = LaveRepository::h5Pay($this->cid, $order);
  127. } else {
  128. $jsConfig = LaveRepository::wxPay($this->cid, $order);
  129. }
  130. } catch (\Exception $e) {
  131. $this->error($e->getMessage());
  132. }
  133. $this->success('获取成功', $jsConfig);
  134. break;
  135. }
  136. return $this->error('支付方式错误');
  137. }
  138. // 支付中签约
  139. public function createSign(Request $request)
  140. {
  141. // var_dump(123);die();
  142. $where = UtilService::postMore(
  143. [
  144. ['cid', $this->cid],
  145. // ['user_id', $this->auth->getUserinfo()['id']],
  146. // ['user_id', 0],
  147. ['order_name', ''],
  148. // ['category_id', 0],
  149. ['amount', 0],
  150. ['name', ''],
  151. ['contact', ''],
  152. ['tel', 0],
  153. ['address', ''],
  154. ['is_open', '0'],
  155. ['is_ticket', '0'],
  156. ['pay_type', '0'],
  157. ['type', '0'],
  158. // ['help_id', 0],
  159. ['plan_id', 0],
  160. ['from', 'weixin'],
  161. ['return_web', '']
  162. ], $request
  163. );
  164. @file_put_contents("quanju.txt", $where['from'] . "-来源\r\n", 8);
  165. if (!$this->auth->isLogin()) {
  166. $this->error(__('Please login first'), null, 401);
  167. }
  168. $return_web = $where['return_web'];
  169. @file_put_contents("quanju3.txt", $return_web . "-返回地址\r\n", 8);
  170. unset($where['return_web']);
  171. $where['user_id'] = $this->auth->getUserinfo()['id'];
  172. $where1 = $where;
  173. unset($where1['from']);
  174. $where1['order_id'] = LaveMonthModel::getNewOrderId();
  175. // $contract_display_account = User::where('id', $where1['user_id'])->value('nickname');
  176. // if (empty($contract_display_account)){
  177. // $this->error('用户不存在!');
  178. // }
  179. if ($where['amount'] > 500) {
  180. $this->error('捐款金额不能大于500');
  181. }
  182. $sign = WechatPlanRecord::where('uid', $where1['user_id'])->where('plan_id', $where1['plan_id'])->where('is_signing', 0)->find();
  183. if (!empty($sign)) {
  184. $this->error('您已签约,请勿重复签约!');
  185. }
  186. if (cache('lave_' . $where['user_id'])) $this->error('正在处理中');
  187. $plan_id = $where1['plan_id'];
  188. @file_put_contents("quanju.txt", $plan_id . "-签约模版编号\r\n", 8);
  189. // unset($where1['plan_id']);
  190. $where1['contract_code'] = WechatPlanRecord::getNewCode();
  191. if ($where['user_id'] != 6779 && $where['user_id'] != 12125) {
  192. $order = LaveMonthModel::create($where1);
  193. if (!$order) $this->error(LaveMonthModel::getErrorInfo());
  194. $orderId = $order['order_id'];
  195. $order['plan_id'] = $plan_id;
  196. } else {
  197. $orderId = $where1['order_id'];
  198. }
  199. $where1['contract_display_account'] = $where1['name'];
  200. cache('lave_' . $where['user_id'], '1', 10);
  201. $info['contract_code'] =$where1['contract_code'];
  202. if ($orderId) {
  203. if ($where['user_id'] != 6779 && $where['user_id'] != 12125&&$where['user_id']!=63) {
  204. $orderInfo = LaveMonthModel::where('order_id', $orderId)->find();
  205. if (!$orderInfo || !isset($orderInfo['paid'])) {
  206. $this->error('支付订单不存在!');
  207. }
  208. if ($orderInfo['paid']) $this->error('支付已支付!');
  209. }
  210. // 创建签约
  211. $plan_record = [
  212. 'plan_id' => $plan_id,
  213. 'cid' => $where['cid'],
  214. 'uid' => $where['user_id'],
  215. 'price' => $where['amount'],
  216. 'is_signing' => 2,
  217. 'contract_code' => $where1['contract_code'],
  218. 'contract_display_account' => $where1['contract_display_account'],
  219. 'is_open' => $where1['is_open'],
  220. 'tel' => $where1['tel'],
  221. // 'category_id'=>$where1['category_id'],
  222. 'order_name' => $where1['order_name'],
  223. ];
  224. $count = WechatPlanRecord::where('uid', $where1['user_id'])->where('plan_id', $plan_id)->count();
  225. $record = WechatPlanRecord::create($plan_record);
  226. @file_put_contents("quanju.txt", json_encode($record) . "-签约模版记录\r\n", 8);
  227. if ($where['user_id'] != 6779 && $where['user_id'] != 12125&&$where['user_id']!=63) {
  228. LaveMonthModel::where('order_id', $orderId)->update(['record_id' => $record['id']]);
  229. }
  230. $plan_record['spbill_create_ip'] = User::where('id', $where1['user_id'])->value('loginip');
  231. $plan_record['contract_notify_url'] = Request::instance()->domain() . "/api/wechat/notify/" . $where['cid'];
  232. try {
  233. if ($where['from'] == 'routine') {
  234. $jsConfig = LaveRepository::jsPaySign($this->cid, $orderId, $plan_record); //创建订单jspay
  235. } else if ($where['from'] == 'weixinh5') {
  236. $jsConfig = LaveRepository::h5PaySign($this->cid, $orderId, $plan_record);
  237. } else {
  238. @file_put_contents("quanju3.txt", $return_web . "-返回地址3\r\n", 8);
  239. $jsConfig = LaveRepository::wxPaySign($this->cid, $orderId, $plan_record,$return_web );
  240. }
  241. } catch (\Exception $e) {
  242. return $this->error($e->getMessage());
  243. }
  244. $info['jsConfig'] = $jsConfig;
  245. // 增加参与人数
  246. // @file_put_contents("quanju.txt", $count."-参与次数\r\n", 8);
  247. if ($count == 0) {
  248. $num = WechatPlan::where('plan_id', $plan_id)->value('num');
  249. // @file_put_contents("quanju.txt", $num."-参与人数\r\n", 8);
  250. WechatPlan::where('plan_id', $plan_id)->update(['num' => $num + 1]);
  251. }
  252. return $this->success('订单创建成功', $info);
  253. } else $this->error(LaveMonthModel::getErrorInfo());
  254. }
  255. public function select_sign(Request $request){
  256. $contract_code = UtilService::postMore(
  257. [
  258. ['contract_code', ''],
  259. ], $request
  260. );
  261. $is_signing = WechatPlanRecord::where('contract_code', $contract_code)->value('is_signing');
  262. return $this->success('获取成功', $is_signing);
  263. }
  264. // 申请扣款
  265. public function payPap(Request $request)
  266. {
  267. // @file_put_contents("quanju.txt", "测试申请扣款-\r\n", 8);
  268. // die();
  269. $list = WechatPlanRecord::where('is_signing', 0)->select();
  270. // $cid=$this->cid;
  271. // $arr=[];
  272. // $arr['body']='月捐款';
  273. foreach ($list as $k => $v) {
  274. $day = intval(date('d', $v['createtime']));
  275. $date = date('Y-m', $v['createtime']);
  276. $last = intval(date("t", time())); //当月最后一天
  277. // @file_put_contents("quanju.txt", $day."-日期\r\n", 8);
  278. $today = intval(date('d'));
  279. $now_date = date('Y-m', time());
  280. $tf = false;
  281. if ($day == 1 && $today == $last) { //签约时间是第一天,且今天是这个月的最后一天
  282. $tf = true;
  283. }
  284. if ($day - 1 > $last && $today == $last) { //签约时间的前一天日期依然比这个月的最后一天大,且今天是这个月的最后一天
  285. $tf = true;
  286. }
  287. if ($date != $now_date) { //先确定月份不同
  288. if ($today == $day - 1 || $tf) { //再确定是不是今天是不是签约日期的前一天
  289. // var_dump(789456132);die();
  290. @file_put_contents("quanju.txt", json_encode($v) . "-月捐数据\r\n", 8);
  291. $cid = $v['cid'];
  292. $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
  293. $where1['cid'] = $cid;
  294. $where1['user_id'] = $v['uid'];
  295. $where1['order_name'] = $v['order_name'];
  296. $where1['order_id'] = LaveMonthModel::getNewOrderId();;
  297. // $where1['category_id']=$v['category_id'];
  298. $where1['amount'] = $v['price'];
  299. $where1['name'] = $v['contract_display_account'];
  300. $where1['contact'] = '';
  301. $where1['tel'] = $v['tel'];
  302. $where1['address'] = '用户未填写联系地址';
  303. $where1['is_open'] = $v['is_open'];
  304. $where1['is_ticket'] = '0';
  305. $where1['type'] = '0';
  306. $where1['record_id'] = $v['id'];
  307. $where1['contract_code'] = $v['contract_code'];
  308. $where1['plan_id'] = $v['plan_id'];
  309. $where1['nonce_str'] = uniqid();
  310. // $where1['help_id']='0';
  311. // @file_put_contents("quanju.txt", json_encode($where1)."测试申请扣款-\r\n", 8);
  312. $order = LaveMonthModel::create($where1);
  313. // }
  314. // var_dump(988745613);die();
  315. $rs = WechatService::papPayApply($mch_id, $where1['order_id'], $where1['amount'], "lave", '月捐款', 'PAP', [], $cid, $v['contract_id'], $where1['order_name'], $where1['nonce_str']);
  316. @file_put_contents("quanju.txt", json_encode($rs) . "-月捐汇报\r\n", 8);
  317. }
  318. }
  319. }
  320. // die();
  321. $this->success('扣款完成');
  322. // }
  323. }
  324. // 申请进行第一次的扣款
  325. public static function paySignPap($contract_code)
  326. {
  327. @file_put_contents("quanju3.txt", $contract_code . "测试申请扣款-\r\n", 8);
  328. // die();
  329. $plan = WechatPlanRecord::where('contract_code', $contract_code)->find();
  330. if ($plan['uid'] != 6779 && $plan['uid'] != 12125&&$plan['uid']!=63) {
  331. return false;
  332. }
  333. @file_put_contents("quanju3.txt", $plan['uid'] . "测试申请扣款uid-\r\n", 8);
  334. if (!empty($plan)) {
  335. $cid = $plan['cid'];
  336. $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
  337. $where1['cid'] = $cid;
  338. $where1['user_id'] = $plan['uid'];
  339. $where1['order_name'] = $plan['order_name'];
  340. $where1['order_id'] = LaveMonthModel::getNewOrderId();;
  341. // $where1['category_id']=$v['category_id'];
  342. $where1['amount'] = $plan['price'];
  343. $where1['name'] = $plan['contract_display_account'];
  344. $where1['contact'] = '';
  345. $where1['tel'] = $plan['tel'];
  346. $where1['address'] = '用户未填写联系地址';
  347. $where1['is_open'] = $plan['is_open'];
  348. $where1['is_ticket'] = '0';
  349. $where1['type'] = '0';
  350. $where1['record_id'] = $plan['id'];
  351. $where1['contract_code'] = $plan['contract_code'];
  352. $where1['plan_id'] = $plan['plan_id'];
  353. $where1['nonce_str'] = uniqid();
  354. // $where1['help_id']='0';
  355. // @file_put_contents("quanju.txt", json_encode($where1)."测试申请扣款-\r\n", 8);
  356. $order = LaveMonthModel::create($where1);
  357. // }
  358. @file_put_contents("quanju3.txt", $order . "测试申请扣款创建订单-\r\n", 8);
  359. // var_dump(988745613);die();
  360. $rs = WechatService::papPayApply($mch_id, $where1['order_id'], $where1['amount'], "lave", '月捐款', 'PAP', [], $cid, $plan['contract_id'], $where1['order_name'], $where1['nonce_str']);
  361. @file_put_contents("quanju3.txt", json_encode($rs) . "-测试申请扣款月捐汇报\r\n", 8);
  362. // }
  363. // }
  364. }
  365. return true;
  366. }
  367. // 检查签约用户是否有符合签约月份数量的扣款记录
  368. public function check_pay_pap()
  369. {
  370. $list = WechatPlanRecord::where('is_signing', 0)->select(); //签约中
  371. @file_put_contents("quanju2.txt", "补漏每月扣款-\r\n", 8);
  372. foreach ($list as $k => $v) {
  373. // 查找对应签约协议号的月捐记录
  374. // $count = LaveMonthModel::where('contract_code', $v['contract_code'])->count();
  375. // $createDate = new \DateTime('@'.$v['createtime']);
  376. // $currentDate = new \DateTime();
  377. // $interval = $currentDate->diff($createDate);
  378. // $monthsDiff = $interval->y * 12 + $interval->m;
  379. // if ($interval->d > 0) {
  380. // $monthsDiff += $interval->d / $currentDate->format('t');
  381. // }
  382. // $monthsDiff = floor($monthsDiff);
  383. // if ($monthsDiff > 0&&$monthsDiff > $count+1) { //相差月数大于月捐记录数量
  384. @file_put_contents("quanju2.txt", $v['contract_code'] . "签约协议号-\r\n", 8);
  385. // @file_put_contents("quanju2.txt", $monthsDiff."相差月份-\r\n", 8);
  386. // @file_put_contents("quanju2.txt", $count."统计次数-\r\n", 8);
  387. // 查找上个月是否有扣款记录
  388. // 获取当前时间的时间戳
  389. $currentTimestamp = time();
  390. // 获取一个月前的时间戳
  391. $last_month = strtotime("-1 month", $currentTimestamp);
  392. $count = LaveMonthModel::where('contract_code', $v['contract_code'])->where('createtime', '>', $last_month)->count();
  393. if ($count == 0) {
  394. @file_put_contents("quanju2.txt", "没有上个月的扣款记录-\r\n", 8);
  395. $cid = $v['cid'];
  396. $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
  397. $where1['cid'] = $cid;
  398. $where1['user_id'] = $v['uid'];
  399. $where1['order_name'] = $v['order_name'];
  400. $where1['order_id'] = LaveMonthModel::getNewOrderId();;
  401. // $where1['category_id']=$v['category_id'];
  402. $where1['amount'] = $v['price'];
  403. $where1['name'] = $v['contract_display_account'];
  404. $where1['contact'] = '';
  405. $where1['tel'] = $v['tel'];
  406. $where1['address'] = '用户未填写联系地址';
  407. $where1['is_open'] = $v['is_open'];
  408. $where1['is_ticket'] = '0';
  409. $where1['type'] = '0';
  410. $where1['record_id'] = $v['id'];
  411. $where1['contract_code'] = $v['contract_code'];
  412. $where1['plan_id'] = $v['plan_id'];
  413. $where1['nonce_str'] = uniqid();
  414. $order = LaveMonthModel::create($where1);
  415. $rs = WechatService::papPayApply($mch_id, $where1['order_id'], $where1['amount'], "lave", '月捐款', 'PAP', [], $cid, $v['contract_id'], $where1['order_name'], $where1['nonce_str']);
  416. // }
  417. @file_put_contents("quanju2.txt", json_encode($rs) . "-补偿月捐汇报\r\n", 8);
  418. }
  419. }
  420. $this->success('获取成功');
  421. }
  422. // 解除签约
  423. public function deleteSign(Request $request)
  424. {
  425. $where = UtilService::postMore(
  426. [
  427. ['id', 0],
  428. ['cid', $this->cid],
  429. ['user_id', $this->auth->getUserinfo()['id']],
  430. ], $request
  431. );
  432. if ($where['id'] == 0) {
  433. $sign_info = WechatPlanRecord::where('cid', $where['cid'])->where('uid', $where['user_id'])->where('is_signing', 0)->find();
  434. } else {
  435. $sign_info = WechatPlanRecord::where('id', $where['id'])->where('is_signing', 0)->find();
  436. }
  437. if (!$sign_info) {
  438. $this->error('未找到签约信息!');
  439. }
  440. $mch_id = Company::where('id', $where['cid'])->value('pay_weixin_mchid');
  441. $plan_id = $sign_info['plan_id'];
  442. $contract_code = $sign_info['contract_code'];
  443. // $mch_id,$contract_code,$pan_id,$version='1.0',$options=[],$cid=0)
  444. $rs = WechatService::deleteSign($mch_id, $contract_code, $plan_id, '1.0', [], $where['cid']);
  445. // @file_put_contents("quanju.txt", json_encode($rs)."-解除签约返回结果\r\n", 8);
  446. $this->success('解除签约成功!');
  447. // if ($rs){
  448. // WechatPlanRecord::where('cid', $where['cid'])->where('uid', $where['user_id'])->where('is_signing',0)->update(['is_signing'=>1]);
  449. // $this->success('解除签约成功!');
  450. // }else{
  451. // $this->error('解除签约失败!');
  452. // }
  453. }
  454. public function plan_lst(Request $request)
  455. {
  456. $where = UtilService::getMore(
  457. [
  458. ['page', 1],
  459. ['limit', 10],
  460. ['cid', $this->cid],
  461. // ['paid', 1],
  462. // ['category_id', 0],
  463. // ['order', ''],
  464. // ['key', ''],
  465. ], $request
  466. );
  467. $this->success('获取成功', WechatPlan::lst($where));
  468. }
  469. public function plan_read(Request $request)
  470. {
  471. $where = UtilService::getMore(
  472. [
  473. ['id', 0],
  474. ['cid', $this->cid],
  475. ], $request
  476. );
  477. @file_put_contents("quanju.txt", $where['cid'] . "-cid是多少\r\n", 8);
  478. if (!$where['id']) $this->error('参数错误');
  479. $this->success('获取成功', WechatPlan::read($where));
  480. }
  481. // 签约列表
  482. public function user_plan_lst(Request $request)
  483. {
  484. $where = UtilService::getMore(
  485. [
  486. // ['cid', 0],
  487. ['cid', $this->cid],
  488. ['uid', $this->auth->getUserinfo()['id']],
  489. // ['uid', 0],
  490. ], $request
  491. );
  492. if (!isset($where['uid'])) $this->error('用户不存在');
  493. if (!isset($where['cid'])) $this->error('请选择正确的城市的红十字会');
  494. $this->success('获取成功', WechatPlanRecord::record_lst($where));
  495. }
  496. // 签约记录详情
  497. public function user_record_info(Request $request)
  498. {
  499. $where = UtilService::getMore(
  500. [
  501. ['id', 0],
  502. // ['cid', 0],
  503. ['cid', $this->cid],
  504. ['user_id', $this->auth->getUserinfo()['id']],
  505. // ['user_id', 0],
  506. ], $request
  507. );
  508. $this->success('获取成功', WechatPlanRecord::record_info($where));
  509. }
  510. // 签约记录详情
  511. public function query_sign_order(Request $request)
  512. {
  513. $where = UtilService::getMore(
  514. [
  515. ['order_id', 0],
  516. ['cid', 0],
  517. ], $request
  518. );
  519. $this->success('获取成功', WechatService::querySignOrder($where['order_id'], $where['cid']));
  520. }
  521. //
  522. public function day_query_sign_order(Request $request)
  523. {
  524. // 改成搜索三天内的未支付订单
  525. $threeDaysAgo = strtotime('-3 days');
  526. @file_put_contents("quanju2.txt", $threeDaysAgo . "-三天前时间戳\r\n", 8);
  527. $list = LaveMonth::where('paid', 0)->where('cid', '>', 1)->where('createtime', '>', $threeDaysAgo)->select();
  528. foreach ($list as $k => $v) {
  529. WechatService::querySignOrder($v['order_id'], $v['cid']);
  530. }
  531. $this->success('修改成功!');
  532. }
  533. public function querycontract(Request $request)
  534. {
  535. $where = UtilService::getMore(
  536. [
  537. ['contract_id', 0],
  538. ['cid', 0],
  539. ], $request
  540. );
  541. $mch_id = Company::where('id', $where['cid'])->value('pay_weixin_mchid');
  542. $this->success('获取成功', WechatService::querycontract($mch_id, $where['contract_id'], '1.0', [], $where['cid']));
  543. }
  544. }
  545. ?>