正在显示
1 个修改的文件
包含
30 行增加
和
2 行删除
@@ -11,6 +11,7 @@ use think\Hook; | @@ -11,6 +11,7 @@ use think\Hook; | ||
11 | use EasyWeChat\Factory; | 11 | use EasyWeChat\Factory; |
12 | use think\Db; | 12 | use think\Db; |
13 | use app\common\model\Attachment; | 13 | use app\common\model\Attachment; |
14 | +use think\process\exception\Timeout; | ||
14 | 15 | ||
15 | /** | 16 | /** |
16 | * 公共接口 | 17 | * 公共接口 |
@@ -430,7 +431,7 @@ class Common extends Api | @@ -430,7 +431,7 @@ class Common extends Api | ||
430 | ]; | 431 | ]; |
431 | $app = Factory::officialAccount($config); | 432 | $app = Factory::officialAccount($config); |
432 | try { | 433 | try { |
433 | - $result = $app->refund->byTransactionId($PayOrderInfo['WeChatOrder'], $PayOrderInfo['PayOrder'], $PayOrderInfo['money'] * 100, $TuiMoney*100); // 总金额 100, 退款 80,操作员:商户号 | 434 | + $result = $app->refund->byTransactionId($PayOrderInfo['WeChatOrder'], $PayOrderInfo['PayOrder'], $PayOrderInfo['money'] * 100, $TuiMoney * 100); // 总金额 100, 退款 80,操作员:商户号 |
434 | //更改订单状态为已退款 | 435 | //更改订单状态为已退款 |
435 | Db::name('pay_order')->where('OrderSn', $OrderSn)->where('PayOrder', $PayOrderInfo['PayOrder'])->update(['type' => 0]); | 436 | Db::name('pay_order')->where('OrderSn', $OrderSn)->where('PayOrder', $PayOrderInfo['PayOrder'])->update(['type' => 0]); |
436 | } catch (Exception $e) { | 437 | } catch (Exception $e) { |
@@ -513,7 +514,7 @@ class Common extends Api | @@ -513,7 +514,7 @@ class Common extends Api | ||
513 | ]; | 514 | ]; |
514 | $app = Factory::officialAccount($config); | 515 | $app = Factory::officialAccount($config); |
515 | try { | 516 | try { |
516 | - $result = $app->refund->byTransactionId($PayOrderInfo['WeChatOrder'], $PayOrderInfo['PayOrder'], $PayOrderInfo['money'] * 100, $TuiMoney*100); // 总金额 100, 退款 80,操作员:商户号 | 517 | + $result = $app->refund->byTransactionId($PayOrderInfo['WeChatOrder'], $PayOrderInfo['PayOrder'], $PayOrderInfo['money'] * 100, $TuiMoney * 100); // 总金额 100, 退款 80,操作员:商户号 |
517 | //更改订单状态为已退款 | 518 | //更改订单状态为已退款 |
518 | Db::name('pay_order')->where('OrderSn', $OrderSn)->where('PayOrder', $PayOrderInfo['PayOrder'])->update(['type' => 0]); | 519 | Db::name('pay_order')->where('OrderSn', $OrderSn)->where('PayOrder', $PayOrderInfo['PayOrder'])->update(['type' => 0]); |
519 | } catch (Exception $e) { | 520 | } catch (Exception $e) { |
@@ -661,4 +662,31 @@ class Common extends Api | @@ -661,4 +662,31 @@ class Common extends Api | ||
661 | ); | 662 | ); |
662 | $this->res($res); | 663 | $this->res($res); |
663 | } | 664 | } |
665 | + | ||
666 | + | ||
667 | + //定时任务 | ||
668 | + public function MonthMoney() | ||
669 | + { | ||
670 | + $Arr = Db::name('agreement')->select(); | ||
671 | + if (!empty($Arr)) { | ||
672 | + foreach ($Arr as $k => $v) { | ||
673 | + if (time() > $v['EXP_time']) { | ||
674 | + if ($v['Money'] > $v['MonthMoney']) { | ||
675 | + //扣钱+时间 | ||
676 | + $res = Db::name('agreement')->where('id', $v['id'])->update(['Money' => $v['Money'] - $v['MonthMoney'], 'EXP_time' => $v['EXP_time'] + 86400 * 30]); | ||
677 | + if (!$res) { | ||
678 | + $this->error('失败id' . $v['id'], 0); | ||
679 | + die; | ||
680 | + } | ||
681 | + } else { | ||
682 | + $res = Db::name('agreement')->where('id', $v['id'])->update(['status' => 3]); | ||
683 | + if (!$res) { | ||
684 | + $this->error('失败id' . $v['id'], 0); | ||
685 | + die; | ||
686 | + } | ||
687 | + } | ||
688 | + } | ||
689 | + } | ||
690 | + } | ||
691 | + } | ||
664 | } | 692 | } |
-
请 注册 或 登录 后发表评论