MobileController.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <?php
  2. namespace mobile\controllers;
  3. use biz\goods\services\CategoryRelateService;
  4. use biz\goods\services\GoodsUsageService;
  5. use biz\goods\services\UsageRelationService;
  6. use Yii;
  7. use common\components\configDict;
  8. use common\components\util;
  9. use common\services\xhCartService;
  10. use common\services\xhGoodsCategoryService;
  11. use common\services\xhGoodsService;
  12. use common\services\xhRecommendService;
  13. use common\services\xhUserAssetService;
  14. use common\services\xhCouponService;
  15. use common\services\xhCategoryService;
  16. use common\services\xhPayToolService;
  17. use common\services\xhOrderGoodsService;
  18. use common\services\xhOrderService;
  19. use common\services\xhGoodsPriceService;
  20. use common\services\xhMerchantExtendService;
  21. use common\services\xhUserService;
  22. use common\services\xhGoodsSettingService;
  23. class MobileController extends MobileendController
  24. {
  25. public $withoutLogin = ['index', 'goods-list', 'goods-detail', 'article', 'article-list', 'login', 'order-alipay', 'choose-pay', 'get-index-more','cert','cert-to'];
  26. public function actionIndex()
  27. {
  28. $slide = xhRecommendService::getSlide($this->merchantId);//首页推荐图片
  29. $list = xhGoodsService::getLimitGoods($this->merchantId);
  30. //首页分类菜单 shish 2019.8.3
  31. Yii::$app->params['merchantId'] = $this->merchantId;
  32. $categoryData = CategoryRelateService::getShowList(8);
  33. $chunkData = array_chunk($categoryData, 4);
  34. $category1 = $chunkData[0];
  35. $category2 = $chunkData[1];
  36. return $this->render('index', ['list' => $list, 'imgList' => $slide, 'category1' => $category1, 'category2' => $category2]);
  37. }
  38. public function actionGetIndexMore()
  39. {
  40. $all = xhGoodsService::getAllGoodsIds($this->merchantId);
  41. $recommend = xhRecommendService::getGoodsIds($this->merchantId);
  42. $remain = array_diff($all, $recommend);
  43. if (empty($remain)) {
  44. util::successInfo();
  45. }
  46. $list = [];
  47. foreach ($remain as $val) {
  48. $info = xhGoodsService::getById($val);
  49. $list[] = $info;
  50. }
  51. util::successInfo('操作成功', 'A0001', ['list' => $list]);
  52. }
  53. //分类与用途 modify shish 2019.8.31
  54. public function actionGoodsList()
  55. {
  56. $get = Yii::$app->request->get();
  57. $id = isset($get['id']) ? $get['id'] : 0;
  58. $type = isset($get['type']) ? $get['type'] : 'category';
  59. $category = [];
  60. $merchantId = $this->merchantId;
  61. $categoryName = '全部宝贝';
  62. if (!empty($id)) {
  63. if ($type == 'category') {
  64. $category = CategoryRelateService::getById($id);
  65. if (empty($category)) {
  66. util::stop('类型无效');
  67. }
  68. $categoryName = $category['showName'];
  69. $list = xhGoodsCategoryService::getGoodsListByCId($id);
  70. if ($category['merchantId'] != $merchantId) {
  71. util::stop('非法访问');
  72. }
  73. } elseif ($type == 'usage') {
  74. $usage = UsageRelationService::getById($id);
  75. if (empty($usage)) {
  76. util::stop('用途无效');
  77. }
  78. if ($usage['merchantId'] != $merchantId) {
  79. util::stop('非法访问');
  80. }
  81. $respond = GoodsUsageService::getGoodsList($id);
  82. $list = $respond['goodsList'];
  83. $info = $respond['info'];
  84. $categoryName = $info['showName'];
  85. $category = $info;
  86. $category['categoryName'] = $categoryName;
  87. } else {
  88. util::fail('无效类型');
  89. }
  90. } else {
  91. $list = xhGoodsService::getAllGoodsList($this->merchantId);
  92. }
  93. $this->webTitle = $categoryName;
  94. return $this->render('goodsList', ['list' => $list, 'category' => $category, 'type' => $type]);
  95. }
  96. public
  97. function actionGoodsDetail()
  98. {
  99. $this->layout = 'goodsMain';
  100. $get = Yii::$app->request->get();
  101. $id = isset($get['id']) ? $get['id'] : 0;
  102. $goods = xhGoodsService::getById($id);
  103. if (empty($goods) || $goods['merchantId'] != $this->merchantId) {
  104. util::stop('访问出错了');
  105. }
  106. if (isset($get['cId']) && $get['cId'] != 0) {
  107. $category = xhCategoryService::getById($get['cId']);
  108. $categoryName = $category['categoryName'];
  109. $this->webTitle = $categoryName . '-' . $this->webTitle;
  110. }
  111. $this->webTitle = $goods['goodsName'] . '-' . $this->webTitle;
  112. //多选价格
  113. if ($goods['multiPrice'] != '') {
  114. $multiPriceStr = $goods['multiPrice'];
  115. $sortGoodsPriceArr = $goodsPriceArr = xhGoodsPriceService::getByIds($multiPriceStr, $id);
  116. $goods['goodsPriceArr'] = $goodsPriceArr;
  117. $sortGoodsPriceArr = \common\components\util::arraySequence($sortGoodsPriceArr, 'price');
  118. $maxPrice = $sortGoodsPriceArr[0]['price'];
  119. $temp = end($sortGoodsPriceArr);
  120. $minPrice = $temp['price'];
  121. $goods['price'] = $minPrice . '-' . $maxPrice;
  122. }
  123. return $this->render('goodsDetail', ['goods' => $goods, 'merchant' => $this->merchant]);
  124. }
  125. public
  126. function actionGoodsOrder()
  127. {
  128. $this->layout = 'goodsMain';
  129. $post = Yii::$app->request->post();
  130. //dump($post);die;
  131. if (isset($post['goodsInfo']) == false || empty($post['goodsInfo'])) {
  132. util::stop('没有商品信息');
  133. }
  134. if (isset($post['sourceType']) == false) {
  135. util::stop('未知来源,不确定来自购物车还是单个商品');
  136. }
  137. if (isset($post['sourceType']) && $post['sourceType'] == 'cart') {
  138. $post['sourceType'] = 0;//商城订单
  139. }
  140. if (!is_numeric($post['sourceType'])) {
  141. util::stop('订单来源参数类型出错');
  142. }
  143. $sourceType = $post['sourceType'];
  144. $goodsList = [];
  145. $totalPrice = 0;
  146. foreach ($post['goodsInfo'] as $key => $val) {
  147. $multiPriceId = 0;
  148. if (isset($val['check']) && !empty($val['check'])) {
  149. $goods = xhGoodsService::getById($val['goodsId']);
  150. if (isset($val['multiPriceId']) && $val['multiPriceId'] > 0) {//商品是否 多选价格
  151. $multiPriceId = $val['multiPriceId'];
  152. $goodPrice = xhGoodsPriceService::getById($multiPriceId);
  153. //$goods['price'] = $goodPrice['price'];
  154. $goods['price'] = xhGoodsSettingService::changePrice($goods, $goodPrice['price']);//统一对商品进行价格等方面设置
  155. $goods['subGoodsName'] = $goodPrice['title'];
  156. }
  157. $totalPrice += $val['num'] * $goods['price'];
  158. $goodsList[] = ['goods' => $goods, 'goodsId' => $val['goodsId'], 'num' => $val['num'], 'multiPriceId' => $multiPriceId];
  159. }
  160. }
  161. if (empty($goodsList)) {
  162. return;
  163. }
  164. $userId = $this->userId;
  165. $userAsset = xhUserAssetService::getByUserId($userId);
  166. $discountPrice = $totalPrice;
  167. $discount = 0;//打几折
  168. $level = $userAsset['memberLevel'];
  169. if ($level > 0) {//如果是会员
  170. $gradeList = xhMerchantExtendService::getGradeList($this->merchantExtend);
  171. $discount = $gradeList[$level]['discount'];
  172. $discount = strlen($discount) == 1 ? $discount * 10 : $discount;
  173. $discountPrice = number_format($discount * $totalPrice / 100, 2);
  174. }
  175. $this->webTitle = '确认订单';//标题
  176. $freight = configDict::getConfig('freight');//运费计算
  177. $coupon = xhCouponService::getUserValidCoupon($userId, $discountPrice);
  178. return $this->render('goodsOrder',
  179. [
  180. 'user' => $this->user,
  181. 'goodsInfo' => $goodsList,
  182. 'totalPrice' => $totalPrice,
  183. 'userAsset' => $userAsset,
  184. 'discount' => $discount,
  185. 'discountPrice' => $discountPrice,
  186. 'sourceType' => $sourceType,
  187. 'merchant' => $this->merchant,
  188. 'freight' => $freight,
  189. 'coupon' => $coupon,
  190. 'extend' => $this->merchantExtend,
  191. ]);
  192. }
  193. /**
  194. * 订单提交
  195. */
  196. public
  197. function actionCreateOrder()
  198. {
  199. $post = Yii::$app->request->post();
  200. //dump($post);die;
  201. $userId = $this->userId;
  202. $post['userId'] = $userId;
  203. $post['payWay'] = $this->isWeixin == true ? 0 : 1;
  204. $lat2 = $post['receiveLat'];//收货人纬度
  205. $lng2 = $post['receiveLong'];//收货人经度
  206. $lat1 = $this->merchant['shopLat'];//花店纬度
  207. $lng1 = $this->merchant['shopLong'];//花店经度
  208. $calcDistance = util::getDistance($lat1, $lng1, $lat2, $lng2);//防止别人改动,PHP计算的距离会比腾讯js算的小,但能保证有一定准确性
  209. $post['sendDistance'] = $post['sendDistance'] >= $calcDistance ? $post['sendDistance'] : $calcDistance;//二地距离
  210. $sendDistance = $post['sendDistance'];
  211. $freight = configDict::getConfig('freight');
  212. $firstDistance = $freight['firstDistance'];
  213. $firstPrice = $freight['firstPrice'];
  214. $nextDistance = $freight['nextDistance'];
  215. $nextPrice = $freight['nextPrice'];
  216. if ($sendDistance <= $firstDistance && $post['isCharge'] == 1) {
  217. $post['sendCost'] = $firstPrice;
  218. } else if ($post['isCharge'] == 1) {
  219. $subDistance = $sendDistance - $firstDistance;
  220. $addPrice = intval($subDistance / $nextDistance) * $nextPrice;
  221. $post['sendCost'] = $firstPrice + $addPrice;
  222. }
  223. if (empty($this->merchantExtend['payment'])) {
  224. util::failInfo('支付功能未开通,暂时无法购买哦~');
  225. }
  226. $couponAmount = 0;
  227. $couponId = isset($post['couponId']) ? $post['couponId'] : 0;//代金劵
  228. if (!empty($couponId)) {
  229. $coupon = xhCouponService::getById($couponId);
  230. $couponUserId = $coupon['userId'];
  231. if ($couponUserId != $userId) {
  232. util::failInfo('不是你的代金劵');
  233. }
  234. if ($coupon['useStatus'] == 1 || $coupon['deadline'] < time()) {
  235. util::failInfo('代金劵已经失效了');
  236. }
  237. $couponAmount = $coupon['amount'];
  238. }
  239. //不要将代金劵保存到订单表,付款成功后再保存进去!!!
  240. unset($post['couponId']);
  241. $post['merchantId'] = $this->merchantId;
  242. //店铺id
  243. $post['shopId'] = $this->merchant['defaultShopId'];
  244. $order = xhOrderService::add($post);//创建订单
  245. if ($order == false) {
  246. util::failInfo('创建订单失败');
  247. }
  248. $orderId = $order['id'];
  249. $oData = [];
  250. $goodsInfo = $post['goodsInfo'];
  251. $totalFee = 0;//计算总价格
  252. $goodsIdList = [];
  253. $multiPriceIdList = [];
  254. $orderName = '';
  255. $goodsNum = 0;
  256. foreach ($goodsInfo as $key => $val) {
  257. $multiPriceId = 0;//多种价格表Id
  258. $goodsId = $val['goodsId'];
  259. $num = $val['num'];
  260. $goodsNum += $num;
  261. $goods = xhGoodsService::getById($goodsId);
  262. if (empty($orderName)) {
  263. $orderName = $goods['goodsName'];
  264. }
  265. $price = $goods['price'];
  266. if ($val['multiPriceId'] != 0 && $goods['multiPrice'] != '') {
  267. $pos = strpos($goods['multiPrice'], $val['multiPriceId']);
  268. if ($pos === false) {
  269. util::failInfo('订单的商品不存在');
  270. }
  271. $goodPrice = xhGoodsPriceService::getById($val['multiPriceId']);
  272. //$price = $goodPrice['price'];
  273. $price = xhGoodsSettingService::changePrice($goods, $goodPrice['price']);//统一对商品进行价格等方面设置
  274. //多种价格规格 替换 默认(单价格)
  275. $goods['goodsName'] = $goodPrice['title'];
  276. //$goods['cover'] = $goodPrice['picture'];//后台图片上传功能未开发,暂时使用默认商品图片
  277. $multiPriceId = $val['multiPriceId'];
  278. }
  279. $totalFee += $price * $num;
  280. $goodsIdList[] = $goodsId;
  281. $multiPriceIdList[] = $multiPriceId;
  282. $data = [
  283. 'orderId' => $orderId,
  284. 'goodsId' => $goodsId,
  285. 'userId' => $userId,
  286. 'merchantId' => $this->merchantId,
  287. 'title' => $goods['goodsName'],
  288. 'cover' => $goods['cover'],
  289. 'unitPrice' => $price,
  290. 'num' => $num,
  291. 'multiPriceId' => $multiPriceId,
  292. 'createTime' => date("Y-m-d H:i:s"),
  293. ];
  294. xhOrderGoodsService::add($data);//创建订单商品列表
  295. }
  296. $sendCost = $post['sendCost'];//运费
  297. $oData['goodsNum'] = $goodsNum;//订单的商品数量类型,单个还是多个的
  298. $oData['prePrice'] = $totalFee + $sendCost;
  299. $oData['orderName'] = $goodsNum > 1 ? $orderName . '等' . $goodsNum . '件商品' : $orderName;
  300. if (isset($post['sourceType']) && $post['sourceType'] == 'cart') {
  301. if (!empty($goodsIdList)) {
  302. foreach ($goodsIdList as $key => $goodsId) {
  303. xhCartService::delByIds($userId, $goodsId, $multiPriceIdList[$key]);//删除购物车($userId, $goodsId, $goodsPriceId, $cartId)
  304. }
  305. }
  306. }
  307. $userAsset = xhUserAssetService::getByUserId($userId);
  308. $level = $userAsset['memberLevel'];
  309. if ($level > 0) {
  310. $gradeList = xhMerchantExtendService::getGradeList($this->merchantExtend);
  311. $discount = $gradeList[$level]['discount'];
  312. $discount = strlen($discount) == 1 ? $discount * 10 : $discount;
  313. $totalFee = number_format($discount * $totalFee / 100, 2);
  314. }
  315. $oData['actPrice'] = $totalFee + $sendCost - $couponAmount;
  316. xhOrderService::updateById($orderId, $oData);
  317. util::successInfo('订单创建成功', 'A0001', ['orderId' => $orderId, 'couponId' => $couponId]);
  318. }
  319. public
  320. function actionChoosePay()
  321. {
  322. header('content-type:text/html;charset=utf-8');//支付宝、微信需要
  323. $this->layout = 'goodsMain';
  324. $this->webTitle = '支付订单';//标题
  325. $get = Yii::$app->request->get();
  326. $orderId = isset($get['orderId']) ? $get['orderId'] : 0;
  327. $order = xhOrderService::getById($orderId);
  328. if ($order['merchantId'] != $this->merchantId) {
  329. util::stop('非法访问');
  330. }
  331. $waitForPay = configDict::getConfig('payStatus', 'waitForPay');
  332. if ($order['payStatus'] != $waitForPay) {
  333. if ($this->isWeixin) {
  334. $this->redirect(['success', 'account' => $this->merchant['id'], 'orderId' => $orderId]);
  335. } else {
  336. echo '已经支付成功';
  337. }
  338. util::end();
  339. }
  340. $userId = $order['userId'];
  341. $user = xhUserService::getById($userId);
  342. $totalFee = $order['actPrice'];
  343. $couponId = isset($get['couponId']) ? $get['couponId'] : 0;
  344. $asset = xhUserAssetService::getByUserId($userId);
  345. return $this->render('choosePay', ['orderId' => $orderId, 'asset' => $asset, 'couponId' => $couponId, 'totalFee' => $totalFee, 'user' => $user]);
  346. }
  347. /**
  348. * 获取微信支付的参数
  349. */
  350. public
  351. function actionGetWxParams()
  352. {
  353. ini_set('date.timezone', 'Asia/Shanghai');
  354. $post = Yii::$app->request->post();
  355. $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
  356. $now = time();
  357. $expireTime = $now + 1800;//订单30分钟后过期
  358. if ($this->merchantExtend['payment'] == 0) {
  359. util::failInfo('还没开通支付功能哟~');
  360. }
  361. $orderId = isset($post['orderId']) ? $post['orderId'] : 0;
  362. $order = xhOrderService::getById($orderId);
  363. if (!empty($couponId)) {
  364. $coupon = xhCouponService::getById($couponId);
  365. if ($coupon['useStatus'] == 1 || $now > $coupon['deadline']) {
  366. util::failInfo('代金劵已经失效');
  367. }
  368. if ($coupon['meetAmount'] > $order['prePrice']) {
  369. util::failInfo('消费金额不足' . $coupon['meetAmount'] . '元');
  370. }
  371. }
  372. if ($order['userId'] != 0 && $order['userId'] != $this->userId) {//当 快速下单时,字段userId为0(未保存指定用户);用户操作后,就只能该用户访问
  373. util::failInfo('非法访问');
  374. }
  375. if (!empty($order['deadline']) && $now > $order['deadline']) {
  376. util::failInfo('订单已经过期');
  377. }
  378. if (ceil($order['actPrice']) <= 0) {
  379. util::failInfo('消费金额小于(等于)0');
  380. }
  381. $name = $order['orderName'];
  382. $totalFee = $order['actPrice'];
  383. $openId = $this->user['openId'];
  384. $typeList = configDict::getConfig('capitalType');
  385. $capitalType = $typeList['xhOrder']['id'];
  386. $attach = "couponId=" . $couponId . "&capitalType=" . $capitalType;//将流水类型、代金劵传过去
  387. $weixin = Yii::getAlias("@vendor/weixin");
  388. require_once($weixin . '/lib/WxPay.Api.php');
  389. require_once($weixin . '/example/WxPay.JsApiPay.php');
  390. $input = new \WxPayUnifiedOrder();
  391. $input->SetBody($name);
  392. $input->SetOut_trade_no($orderId);
  393. $input->SetTotal_fee($totalFee * 100);
  394. $input->SetTime_start(date("YmdHis", $now));
  395. $input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传
  396. $input->SetTime_expire(date("YmdHis", $expireTime));
  397. $input->SetNotify_url($this->frontUrl . '/notice/weixin-callback/');
  398. $input->SetTrade_type("JSAPI");
  399. //服务商 代设置微信支付,要添加的参数设置
  400. if ($this->merchantExtend['generalMerchant'] == 1) {
  401. //$input->SetOpenid($openId);
  402. $input->SetSub_openid($openId);
  403. //自设置 微信支付
  404. } else {
  405. $input->SetOpenid($openId);
  406. }
  407. $wxOrder = \WxPayApi::unifiedOrder($input, 6, $this->merchantExtend);
  408. $tools = new \JsApiPay();
  409. $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $this->merchantExtend);
  410. $newParams = json_decode($jsApiParameters, true);
  411. $updateData = ['modPriceStatus' => 1];//已经请求微信不能修改价格
  412. if (empty($order['deadline'])) {
  413. $updateData['deadline'] = $expireTime;
  414. }
  415. xhOrderService::updateById($orderId, $updateData);//已经请求微信不能修改价格
  416. util::successInfo('操作成功', 'A0001', $newParams);
  417. }
  418. /**
  419. * 订单 - 支付宝支付
  420. */
  421. public
  422. function actionOrderAlipay()
  423. {
  424. header("Content-type: text/html; charset=utf-8");
  425. $alipayWap = Yii::getAlias("@vendor/alipayWap");
  426. require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
  427. require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
  428. require_once($alipayWap . '/config.php');
  429. $get = Yii::$app->request->get();
  430. $orderId = isset($get['orderId']) ? $get['orderId'] : 0;
  431. $couponId = isset($get['couponId']) ? $get['couponId'] : 0;
  432. $orderData = xhOrderService::getById($orderId);
  433. $waitForPay = configDict::getConfig('payStatus', 'waitForPay');
  434. if ($orderData['payStatus'] != $waitForPay) {
  435. echo '已经支付成功';
  436. util::end();
  437. }
  438. $merchantId = $orderData['merchantId'];
  439. $out_trade_no = $orderId;//商户订单号,商户网站订单系统中唯一订单号,必填
  440. $subject = $orderData['orderName'];//订单名称,必填
  441. $total_amount = $orderData['actPrice'];;//付款金额,必填
  442. $body = '';//商品描述,可空
  443. $timeout_express = "1m";//超时时间
  444. $typeList = configDict::getConfig('capitalType');
  445. $capitalType = $typeList['xhOrder']['id'];
  446. $passbackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&merchantId=' . $merchantId;//将流水类型、代金劵传过去
  447. $passbackParams = urlencode($passbackParams);
  448. $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
  449. $payRequestBuilder->setBody($body);
  450. $payRequestBuilder->setSubject($subject);
  451. $payRequestBuilder->setOutTradeNo($out_trade_no);
  452. $payRequestBuilder->setTotalAmount($total_amount);
  453. $payRequestBuilder->setTimeExpress($timeout_express);
  454. $payRequestBuilder->setPassbackParams($passbackParams);//在异步通知时将该参数原样返回
  455. $returnUrl = Yii::$app->params['frontUrl'] . "/notice/order-alipay-sync";
  456. $payResponse = new \AlipayTradeService($config);
  457. $result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $config['notify_url']);
  458. $this->renderPartial('alipay', ['result' => $result]);
  459. }
  460. public function actionBalancePay()
  461. {
  462. $post = Yii::$app->request->post();
  463. $orderId = isset($post['orderId']) ? $post['orderId'] : 0;
  464. $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
  465. $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
  466. $order = xhOrderService::getById($orderId);
  467. if ($order['merchantId'] != $this->merchantId || $order['userId'] != $this->userId) {
  468. util::failInfo('非法访问');
  469. }
  470. $actPrice = $order['actPrice'];//不包括打折时需要付款金额
  471. if (!empty($couponId)) {
  472. $coupon = xhCouponService::getById($couponId);
  473. if ($coupon['useStatus'] == 1 || $now > $coupon['deadline']) {
  474. util::failInfo('代金劵已经失效');
  475. }
  476. if ($coupon['meetAmount'] > $actPrice) {
  477. util::failInfo('消费不足' . $coupon['meetAmount'] . '元');
  478. }
  479. }
  480. if (empty($this->user['payPassword'])) {
  481. util::failInfo('您还没有设置支付密码');
  482. }
  483. if (md5($payPassword) != $this->user['payPassword']) {
  484. util::failInfo('支付密码不正确');
  485. }
  486. $typeList = configDict::getConfig('capitalType');
  487. $capitalType = $typeList['xhOrder']['id'];
  488. $totalFee = $order['actPrice'];
  489. $return = xhPayToolService::balancePay($orderId, $totalFee, $capitalType, $couponId);
  490. if ($return['code'] == 'A0002') {
  491. util::failInfo($return['msg']);
  492. }
  493. echo json_encode($return);
  494. }
  495. public
  496. function actionSuccess()
  497. {
  498. $this->layout = 'goodsMain';
  499. $get = Yii::$app->request->get();
  500. $orderId = isset($get['orderId']) ? $get['orderId'] : 0;
  501. $this->webTitle = '支付成功';//标题
  502. return $this->render('success', ['orderId' => $orderId]);
  503. }
  504. public
  505. function actionLogin()
  506. {
  507. return $this->render('login');
  508. }
  509. //国兰证书课跳转临时使用 shish
  510. public function actionCert()
  511. {
  512. return $this->render('cert');
  513. }
  514. public function actionCertTo()
  515. {
  516. header('Location: http://m.fjglhs.com/main/cert');
  517. exit;
  518. }
  519. }