| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace biz\renew\classes;
- use biz\base\classes\BaseClass;
- use biz\shop\classes\ShopClass;
- use biz\sj\classes\SjClass;
- use bizHd\saas\classes\ApplyClass;
- use bizHd\shop\classes\MainInviteClass;
- use common\components\noticeUtil;
- use common\components\util;
- use Yii;
- class RenewClass extends BaseClass
- {
- public static $baseFile = '\biz\renew\models\Renew';
- public static function getRenewList($where)
- {
- $data = self::getList('*', $where, 'addTime DESC');
- return $data;
- }
- public static function thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId)
- {
- $renew = self::getByCondition(['orderSn' => $orderSn], true);
- if (empty($renew)) {
- $msg = "没有找到续费订单 orderSn:{$orderSn}";
- noticeUtil::push($msg, '15280215347');
- util::fail($msg);
- }
- if ($renew->actPrice != $totalFee) {
- $msg = "续费订单金额与回调通知金额不一致 orderSn:{$orderSn} {$renew->actPrice} {$totalFee}";
- noticeUtil::push($msg, '15280215347');
- util::fail($msg);
- }
- if ($renew->status == 1) {
- $msg = '续费订单已付款,重复通知 orderSn:' . $orderSn;
- noticeUtil::push($msg, '15280215347');
- util::fail($msg);
- }
- $attachParams = [];
- if (!empty($attach)) {
- parse_str($attach, $attachParams);
- }
- $applyId = (int) ($attachParams['applyId'] ?? 0);
- $isRegisterMember = $applyId > 0;
- $shopId = $renew->shopId ?? 0;
- $shop = ShopClass::getById($shopId, true);
- if (empty($shop)) {
- $msg = '续费订单没有找到门店 orderSn:' . $orderSn;
- noticeUtil::push($msg, '15280215347');
- util::fail($msg);
- }
- $mainId = $shop->mainId ?? 0;
- $before = $shop->deadline ?? '';
- $beforeTime = strtotime($before);
- if ($renew->type == 2) {
- //购买设备,不需要有操作
- } else {
- //每次续费一年
- $time = $beforeTime + 31536000;
- $newDate = date("Y-m-d H:i:s", $time);
- $renew->deadline = $newDate;
- $renew->beforeDeadline = $before;
- $shopList = ShopClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
- if (!empty($shopList)) {
- foreach ($shopList as $myShop) {
- $myShop->beforeDeadline = $before;
- $myShop->deadline = $newDate;
- $myShop->hasRenew = 1;
- $myShop->needRenew = 0;
- $myShop->save();
- }
- }
- }
- $renew->returnCode = $transactionId;
- $renew->payTime = date("Y-m-d H:i:s");
- $renew->status = 1;
- $renew->save();
- if ($isRegisterMember) {
- $apply = ApplyClass::getById($applyId);
- if (!empty($apply)) {
- MainInviteClass::grantInviterCommission(
- $apply,
- (int) $mainId,
- trim((string) ($apply['name'] ?? '')),
- trim((string) ($apply['mobile'] ?? '')),
- round((float) ($renew->prePrice ?? 0), 2),
- round((float) ($renew->actPrice ?? 0), 2)
- );
- }
- }
- return true;
- }
- }
|