|
|
@@ -5,12 +5,14 @@ namespace ghs\controllers;
|
|
|
use biz\set\classes\SetClass;
|
|
|
use biz\sj\services\MerchantExtendService;
|
|
|
use biz\sj\services\MerchantService;
|
|
|
+use bizGhs\shop\classes\RenewClass;
|
|
|
use bizHd\saas\services\RenewService;
|
|
|
use bizHd\saas\services\SetMealService;
|
|
|
use bizHd\user\services\UserService;
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\httpUtil;
|
|
|
+use common\components\orderSn;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
|
|
|
@@ -24,6 +26,81 @@ class RenewController extends BaseController
|
|
|
util::success($list);
|
|
|
}
|
|
|
|
|
|
+ //创建续费的订单 ssh 20240425
|
|
|
+ public function actionCreate()
|
|
|
+ {
|
|
|
+ ini_set('date.timezone', 'Asia/Shanghai');
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $year = $get['year'] ?? 1;
|
|
|
+ $orderSn = orderSn::getRenewSn();
|
|
|
+ $staff = $this->shopAdmin;
|
|
|
+ $staffId = $staff->id ?? 0;
|
|
|
+ $shopAdminName = $staff->name ?? '';
|
|
|
+ $shop = $this->shop;
|
|
|
+ $shopId = $shop->id ?? 0;
|
|
|
+ $sjId = $shop->sjId ?? 0;
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $pfLevel = $shop->pfLevel ?? 0;
|
|
|
+ $unitPrice = $pfLevel == 0 ? 980 : 1980;
|
|
|
+ $price = bcmul($unitPrice, $year, 2);
|
|
|
+ $data = [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'prePrice' => $price,
|
|
|
+ 'actPrice' => $price,
|
|
|
+ 'shopAdminId' => $staffId,
|
|
|
+ 'shopAdminName' => $shopAdminName,
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'pfLevel' => $pfLevel,
|
|
|
+ 'year' => $year,
|
|
|
+ 'deadline' => $deadline,
|
|
|
+ 'beforeDeadline' => $beforeDeadline,
|
|
|
+ 'status' => 0,
|
|
|
+ ];
|
|
|
+ $ret = RenewClass::add($data, true);
|
|
|
+ $id = $ret->id ?? 0;
|
|
|
+
|
|
|
+ $now = time();
|
|
|
+ $expireTime = $now + 300;//订单5分钟后过期
|
|
|
+ $totalFee = $price;
|
|
|
+ $name = "续费{$year}年";
|
|
|
+
|
|
|
+ $admin = $this->admin;
|
|
|
+ $openId = $admin->ghsMiniOpenId;
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhRenew', 'id');
|
|
|
+ $attach = 'capitalType=' . $capitalType . '&couponId=0&shopId=' . $shopId;
|
|
|
+ $wx = Yii::getAlias("@vendor/weixin");
|
|
|
+ require_once($wx . '/lib/WxPay.Api.php');
|
|
|
+ require_once($wx . '/example/WxPay.JsApiPay.php');
|
|
|
+ $input = new \WxPayUnifiedOrder();
|
|
|
+ $input->SetBody($name);
|
|
|
+ $input->SetOut_trade_no($orderSn);
|
|
|
+ $input->SetTotal_fee($totalFee * 100);
|
|
|
+ $input->SetTime_start(date("YmdHis", $now));
|
|
|
+ $input->SetAttach($attach);
|
|
|
+ $input->SetTime_expire(date("YmdHis", $expireTime));//设置订单有效期5分钟
|
|
|
+ $input->SetNotify_url(Yii::$app->params['ghsHost'] . '/notice/wx-callback/');
|
|
|
+ $input->SetTrade_type("JSAPI");
|
|
|
+
|
|
|
+ //花卉宝代为申请的微信支付
|
|
|
+ $sjExtend = WxOpenClass::getGhsWxInfo();
|
|
|
+ if (isset($sjExtend['wxPayApply']) && $sjExtend['wxPayApply'] == 1) {
|
|
|
+ $input->SetSub_openid($openId);
|
|
|
+ } else {
|
|
|
+ $input->SetOpenid($openId);
|
|
|
+ }
|
|
|
+ //小程序使用miniAppId
|
|
|
+ $sjExtend['wxAppId'] = $sjExtend['miniAppId'];
|
|
|
+
|
|
|
+ $wxOrder = \WxPayApi::unifiedOrder($input, 6, $sjExtend);
|
|
|
+ $tools = new \JsApiPay();
|
|
|
+ $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $sjExtend);
|
|
|
+ $newParams = json_decode($jsApiParameters, true);
|
|
|
+ $newParams['id'] = $id;
|
|
|
+ util::success($newParams);
|
|
|
+ }
|
|
|
+
|
|
|
//微信支付购买 ssh 2020.1.11
|
|
|
public function actionWxPay()
|
|
|
{
|