MobileController.php 20 KB

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