request->get(); $id = isset($get['id']) ? $get['id'] : 0; $order = OrderClass::getById($id, true); if (empty($order)) { util::fail('没有找到订单'); } OrderClass::valid($order, $this->mainId); if ($order->status != 2) { util::fail('订单不是待发货状态,请刷新'); } $order->status = 4; $order->save(); util::complete('操作成功'); } //打印订单 ssh 20220601 public function actionPrintOrder() { $get = Yii::$app->request->get(); $id = isset($get['id']) ? $get['id'] : 0; $order = OrderClass::getById($id, true); if (empty($order)) { util::fail('没有找到订单'); } OrderClass::valid($order, $this->mainId); OrderClass::onlinePrint($order, true); util::complete(); } //微信和支付宝付款码支付复查 ssh 20220422 public function actionCodePayCheck() { ini_set('date.timezone', 'Asia/Shanghai'); header("Content-type: text/html; charset=utf-8"); $get = Yii::$app->request->get(); $id = isset($get['id']) ? $get['id'] : 0; $order = OrderClass::getById($id, true); OrderClass::valid($order, $this->mainId); $orderSn = $order->orderSn ?? ''; $totalFee = $order->mainPay ?? 0; if ($order->status == OrderClass::ORDER_STATUS_COMPLETE) { util::success(['returnStatus' => 'SUCCESS']); } if ($order->status != OrderClass::ORDER_STATUS_UN_PAY) { util::complete('订单不是待付款状态'); } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $payWay = $cg->payWay ?? dict::getDict('payWay', 'wxPay'); $capitalType = dict::getDict('capitalType', 'xhOrder', 'id'); if ($payWay == dict::getDict('payWay', 'wxPay')) { //微信付款 $wx = Yii::getAlias("@vendor/wxPayApi_v3.0.10"); require_once($wx . '/lib/WxPay.Api.php'); require_once($wx . '/example/WxPay.MicroPay.php'); //获取微信商户号等信息 $sjExtend = WxOpenClass::getMallWxInfo(); $microPay = new \MicroPay(); $payReturn = $microPay->query($orderSn, $sjExtend); if ($payReturn["return_code"] == "SUCCESS" && $payReturn["result_code"] == "SUCCESS") { if ($payReturn["trade_state"] == "SUCCESS") { //支付成功 $transactionId = $payReturn['transaction_id'] ?? ''; $order->onlinePay = dict::getDict('onlinePay', 'yes'); $order->save(); $attach = ''; payUtil::thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId); $transaction->commit(); //打印小票和语音播报 $newOrder = OrderClass::getById($id, true); OrderClass::onlinePrint($newOrder); ShopExtClass::hdGatheringReport($newOrder); util::success(['returnStatus' => 'SUCCESS']); } else if ($payReturn["trade_state"] == "USERPAYING") { //用户支付中 util::complete('正在付款,请稍候..'); } } if ($payReturn["err_code"] == "ORDERNOTEXIST") { //交易订单号不存在 util::complete('订单没有付款'); } else { util::complete('系统错误,请稍候再试'); } } elseif ($payWay == dict::getDict('payWay', 'alipay')) { //支付宝付款 $aliF2F = Yii::getAlias("@vendor/alipayF2F"); require_once($aliF2F . '/f2fpay/model/builder/AlipayTradePayContentBuilder.php'); require_once($aliF2F . '/f2fpay/service/AlipayTradeService.php'); // $aliPId = '2017041906821571'; // $aliKey = 'MIIEpAIBAAKCAQEAvbeu6o90L+0AilI+mbhuJJH0lUv7hWQCEC+XUc+cWlC9ulKC3cSVScVLJHpUc09aj6v/iD1p9iVfgMxjeADNVKiQC2RJyRshAjzyTq+2bTcODp619iV2y4qW8UM65VcP7Ide3P0uT5xC2ReW0HpkdHZgm4F+P7mh1VhGt9qOP3hjvoraAHhtGACvsGvy8H69HhSAG+CEmFt7f2tKNWJ8xEUvkfhDvys93PfTk4xMWj048hJE2r38+2mWI/Il5dFQHWXXTVl2x9yi7uhEEW42a+7s9Q3HgqEvZiQ2NI1FTeEAPLFBApiEsNLY/smaszwqqfWGAyTMvtQ6T4K96GcTLQIDAQABAoIBAHwYTj33n9RJfnT73x7F2KXrIsUVcmyKQh88QgqtdmRNNA1QM3HESLJ8bu5pZhwW5/HaW8dOBKWRRKsHBnlUbPrXV4FcFDeLm0fPfd+iZ/2AaZ1+ix962f3BpYIiq7+f9zaMRazfnw9L8x31pByyMktLs12EkoQ0dHsMxxUzzKAOiiPnvCn8Pv+Jb2qej8GXgCjefutCVNMWGsdwJtMVXEbpdmMa48Wvw+0In5ZS/UG39YAreFzgDqI9jWHE1ZhkGmB1+8hKpeI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ohLGnb4m3nnwRVwnNVAaUcVfV1J0Nb0/9pusrj2t6FCyCkFeWbRDzKhplPQejaET2p5yplwSUpd1gqF+3srIn3erW5uAR6F0Z0NoCMzlo5TEXKWY2XMq97ubueE7Cgp8/c3dh5dkscAT2CCWwRq23aKozp+XMwIDAQAB'; $config = array( //签名方式,默认为RSA2(RSA2048) 'sign_type' => "RSA2", //支付宝公钥 'alipay_public_key' => $aliPublicKey, //商户私钥 'merchant_private_key' => $aliKey, //编码格式 'charset' => "UTF-8", //支付宝网关 'gatewayUrl' => "https://openapi.alipay.com/gateway.do", //应用ID 'app_id' => $aliPId, //异步通知地址,只有扫码支付预下单可用 'notify_url' => Yii::$app->params['mallHost'] . "/notice/ali-callback", //最大查询重试次数 'MaxQueryRetry' => "10", //查询间隔 'QueryDuration' => "3" ); //构造查询业务请求参数对象 $queryContentBuilder = new \AlipayTradeQueryContentBuilder(); $queryContentBuilder->setOutTradeNo($orderSn); //初始化类对象,调用queryTradeResult方法获取查询应答 $queryResponse = new \AlipayTradeService($config); $queryResult = $queryResponse->queryTradeResult($queryContentBuilder); if ($queryResult->getTradeStatus() == 'SUCCESS') { $respond = $queryResult->getResponse(); $transactionId = $respond->trade_no ?? ''; $order->onlinePay = dict::getDict('onlinePay', 'yes'); $order->save(); $attach = ''; payUtil::thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId); $transaction->commit(); //打印小票和语音播报 $newOrder = OrderClass::getById($id, true); OrderClass::onlinePrint($newOrder); ShopExtClass::hdGatheringReport($newOrder); util::success(['returnStatus' => 'SUCCESS']); } } else { util::complete('还没有付款哦'); } } catch (\Exception $e) { $transaction->rollBack(); Yii::error("支付失败原因:" . $e->getMessage()); util::complete('支付失败'); } } //微信和支付宝付款码支付 ssh 2021.4.11 public function actionCodePay() { ini_set('date.timezone', 'Asia/Shanghai'); header("Content-type: text/html; charset=utf-8"); $get = Yii::$app->request->get(); $id = isset($get['id']) ? $get['id'] : 0; $order = OrderClass::getById($id, true); OrderClass::valid($order, $this->mainId); $authCode = (string)$get['authCode'] ?? ''; if (empty($authCode)) { util::fail('没有获取到支付码'); } $wxPrefix = ['10', '11', '12', '13', '14', '15']; $isWx = false; foreach ($wxPrefix as $wxId) { if (strpos($authCode, $wxId) === 0) { $isWx = true; } } $orderSn = $order->orderSn ?? ''; $outTradeNo = $orderSn; $subject = '购买商品'; $totalFee = $order->mainPay ?? 0; $totalAmount = $totalFee; $body = "门店"; $capitalType = dict::getDict('capitalType', 'xhOrder', 'id'); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { if ($isWx) { $wxPayWay = dict::getDict('payWay', 'wxPay'); $order->payWay = $wxPayWay; $order->save(); $wx = Yii::getAlias("@vendor/wxPayApi_v3.0.10"); require_once($wx . '/lib/WxPay.Api.php'); require_once($wx . '/example/WxPay.MicroPay.php'); $input = new \WxPayMicroPay(); $input->SetAuth_code($authCode); $input->SetBody($subject); $input->SetTotal_fee($totalFee * 100); $input->SetOut_trade_no($orderSn); //获取微信商户号等信息 $sjExtend = WxOpenClass::getMallWxInfo(); $microPay = new \MicroPay(); $res = $microPay->pay($input, $sjExtend); if (isset($res["return_code"]) && $res["return_code"] == "SUCCESS" && isset($res["result_code"]) && $res["result_code"] == 'SUCCESS') { $transactionId = $res['transaction_id'] ?? ''; $order->onlinePay = dict::getDict('onlinePay', 'yes'); $order->save(); $attach = ''; payUtil::thirdPay($wxPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId); $transaction->commit(); //打印小票和语音播报 $newOrder = OrderClass::getById($id, true); OrderClass::onlinePrint($newOrder); ShopExtClass::hdGatheringReport($newOrder); util::success(['returnStatus' => 'SUCCESS']); } else { Yii::info(json_encode($res)); $returnMsg = $res['return_msg'] ?? ''; Yii::info($returnMsg); $errCode = $res['err_code'] ?? ''; $msg = ''; if ($errCode == 'NOTENOUGH') { $msg = '余额不足'; } if ($errCode == 'USERPAYING') { $msg = '等待客户输入支付密码'; } util::success(['returnStatus' => 'FAILURE'], $msg); } } else { $aliPayWay = dict::getDict('payWay', 'alipay'); $order->payWay = $aliPayWay; $order->save(); $aliF2F = Yii::getAlias("@vendor/alipayF2F"); require_once($aliF2F . '/f2fpay/model/builder/AlipayTradePayContentBuilder.php'); require_once($aliF2F . '/f2fpay/service/AlipayTradeService.php'); // $aliPId = '2017041906821571'; // $aliKey = 'MIIEpAIBAAKCAQEAvbeu6o90L+0AilI+mbhuJJH0lUv7hWQCEC+XUc+cWlC9ulKC3cSVScVLJHpUc09aj6v/iD1p9iVfgMxjeADNVKiQC2RJyRshAjzyTq+2bTcODp619iV2y4qW8UM65VcP7Ide3P0uT5xC2ReW0HpkdHZgm4F+P7mh1VhGt9qOP3hjvoraAHhtGACvsGvy8H69HhSAG+CEmFt7f2tKNWJ8xEUvkfhDvys93PfTk4xMWj048hJE2r38+2mWI/Il5dFQHWXXTVl2x9yi7uhEEW42a+7s9Q3HgqEvZiQ2NI1FTeEAPLFBApiEsNLY/smaszwqqfWGAyTMvtQ6T4K96GcTLQIDAQABAoIBAHwYTj33n9RJfnT73x7F2KXrIsUVcmyKQh88QgqtdmRNNA1QM3HESLJ8bu5pZhwW5/HaW8dOBKWRRKsHBnlUbPrXV4FcFDeLm0fPfd+iZ/2AaZ1+ix962f3BpYIiq7+f9zaMRazfnw9L8x31pByyMktLs12EkoQ0dHsMxxUzzKAOiiPnvCn8Pv+Jb2qej8GXgCjefutCVNMWGsdwJtMVXEbpdmMa48Wvw+0In5ZS/UG39YAreFzgDqI9jWHE1ZhkGmB1+8hKpeIlEeVGAeYVveUgssMORdA/YY8SWHk26KSIFXBrmdKjAcRJ8Q7ZHUmzIqAV+IMV+RD4J5mZHeJgdAECgYEA8J+Hp1M6eYbT4CPLXa//yRP6Xo+qSzrKHaRB1LRAjYhvKpx/TQetYpNCJ5bWpa+Jp0T5R21pzuYaJkPuGlNEHA13b5T3r1l2ltomSEdaShvD5EZ9WtErYV5zpSv7FjjIGkbwa0H3A8Ydnvw5z4A9TZjjHLjC2GtVG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ojSAfcayLroQId8Y3nPqVPpKMwvjvV7r50nGCCqXBtQsF4KITRzqrAoGAZBNyYNgBguRaEd1Sxw2gPmOUfvqiUCo6F4MJ+8xN8idn4FnaofcH8ic613PQPqpB/yYaxeqgIEfnvGY9ILXCuvbePfYqFmMwzALWvZ+v7uVKa2M7HstWCrq7O+m/lQFN/ut8ZnUDcBn4WwwHa/PjCYietetO2gpDRmAdSqrWGH8CgYBkwp+r6pkJzW60kHSZIlEKAe7oJMwLNC2ZqQ4MwGwzfBaH+E34kCuR8ZqYzyAIVOa/Nwi5By1Zvi1KzBwJmUUTJ3o7WCOE96EzSrmOZlqXNCwO/36Vh6dshhhE/birIlXJSP0xdzpBQy2ksyli9eGy8cdJ2Y72Wo+TjSclRbKiPQKBgQD1C/CJRQbahz6B3Sc4NOiFUQioM30qDKbDibzUq95u5PtQOx69+/h68tA2nj7ILZOXoh6/KF6LM9WK0QctY0HR5Uy4Uz8YkY/Y0L/LExSkNdpYqbpBc8DdIsKYHoMLNHDwc03tpINRLrmq00sD0907oeuY8/2l6P7XOZSnCvE5Fw=='; $aliPublicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgEb9zdQQDva63DhksZHPZCDrRe2xvZcTRy9mEiWs/pUhCG0QABkuePUyvqTAKINiCEv2QJmdF8qt3hmTSXuME5bT4vghckSGUTp4CNzsT90Vfjk4wci+bpAqNnpUASDuqZLCzebTuOhxYtGVBqYzhp/CxcC/Mag3ISjUG6jRqyUi15R1e2ruq74sohLGnb4m3nnwRVwnNVAaUcVfV1J0Nb0/9pusrj2t6FCyCkFeWbRDzKhplPQejaET2p5yplwSUpd1gqF+3srIn3erW5uAR6F0Z0NoCMzlo5TEXKWY2XMq97ubueE7Cgp8/c3dh5dkscAT2CCWwRq23aKozp+XMwIDAQAB'; $config = array( //签名方式,默认为RSA2(RSA2048) 'sign_type' => "RSA2", //支付宝公钥 'alipay_public_key' => $aliPublicKey, //商户私钥 'merchant_private_key' => $aliKey, //编码格式 'charset' => "UTF-8", //支付宝网关 'gatewayUrl' => "https://openapi.alipay.com/gateway.do", //应用ID 'app_id' => $aliPId, //异步通知地址,只有扫码支付预下单可用 'notify_url' => Yii::$app->params['mallHost'] . "/notice/ali-callback", //最大查询重试次数 'MaxQueryRetry' => "10", //查询间隔 'QueryDuration' => "3" ); // 支付超时,线下扫码交易定义为5分钟 $timeExpress = "5m"; // 创建请求builder,设置请求参数 $barPayRequestBuilder = new \AlipayTradePayContentBuilder(); $barPayRequestBuilder->setOutTradeNo($outTradeNo); $barPayRequestBuilder->setTotalAmount($totalAmount); $barPayRequestBuilder->setAuthCode($authCode); $barPayRequestBuilder->setTimeExpress($timeExpress); $barPayRequestBuilder->setSubject($subject); $barPayRequestBuilder->setBody($body); // 调用barPay方法获取当面付应答 $barPay = new \AlipayTradeService($config); $barPayResult = $barPay->barPay($barPayRequestBuilder); if ($barPayResult->getTradeStatus() == 'SUCCESS') { $respond = $barPayResult->getResponse(); $transactionId = $respond->trade_no ?? ''; $order->onlinePay = dict::getDict('onlinePay', 'yes'); $order->save(); $attach = ''; payUtil::thirdPay($aliPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId); $transaction->commit(); //打印小票和语音播报 $newOrder = OrderClass::getById($id, true); OrderClass::onlinePrint($newOrder); ShopExtClass::hdGatheringReport($newOrder); util::success(['returnStatus' => 'SUCCESS']); } util::success(['returnStatus' => 'FAILURE']); } } catch (\Exception $e) { $transaction->rollBack(); Yii::error("支付失败原因:" . $e->getMessage()); util::fail('支付失败'); } } //开单操作 ssh 20220316 public function actionCreateOrder() { $post = Yii::$app->request->post(); $post['sjId'] = $this->sjId; $post['shopId'] = $this->shopId; $post['mainId'] = $this->mainId ?? 0; $now = time(); $orderValidTime = getenv('ORDER_VALID_TIME') == false ? 600 : getenv('ORDER_VALID_TIME'); $expireTime = $now + $orderValidTime; $post['deadline'] = $expireTime; $post['staffId'] = $this->shopAdminId ?? 0; $post['staffName'] = $this->shopAdmin->name ?? ''; //默认情况开单员工和收款员工是同个人 $staffId = $this->shopAdminId ?? 0; $post['shopAdminId'] = $staffId; if (isset($post['getStaffId']) == false || empty($post['getStaffId'])) { $post['getStaffId'] = $staffId; $post['getStaffName'] = $this->shopAdmin->name ?? ''; } $post['shopAdminName'] = $this->shopAdmin->name ?? ''; $groupId = isset($post['groupId']) && !empty($post['groupId']) ? $post['groupId'] : 0; $post['fromType'] = $post['fromType'] ?? 1; if ($post['fromType'] == dict::getDict('fromType', 'friend')) { if (isset($post['bookName']) == false || empty($post['bookName'])) { util::fail('请填写订花人姓名,没有填【无】'); } } $customId = isset($post['customId']) && $post['customId'] > 0 ? $post['customId'] : 0; if (empty($customId)) { $customId = $this->shop->defaultCustomId ?? 0; } $custom = CustomClass::getById($customId); if (empty($custom)) { util::fail('没有找到客户哦'); } $post['customId'] = $customId; if (isset($post['receiveMobile']) && !empty($post['receiveMobile'])) { if (stringUtil::isMobile($post['receiveMobile']) == false) { util::fail('请填写正确的收花人手机号'); } } if (isset($post['bookMobile']) && !empty($post['bookMobile'])) { if (stringUtil::isMobile($post['bookMobile']) == false) { util::fail('请填写正确的订花人手机号'); } } $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay'); if (isset($post['isCashier']) && $post['isCashier'] == 1) { //收银台开单默认到店自取 $post['sendType'] = dict::getDict('sendType', 'shopGet'); } $productJson = $post['product'] ?? ''; $productList = []; if (!empty($productJson)) { $productList = json_decode($productJson, true); } if (empty($productList) && empty($groupId)) { //商家手机上开单并生成制作单 if (isset($post['unitGoodsPrice']) && !empty($post['unitGoodsPrice'])) { $unitGoodsPrice = $post['unitGoodsPrice']; if (is_numeric($unitGoodsPrice) == false) { util::fail('请输入正确的单价'); } $productList = GoodsClass::orderCreateGoods($post); } } if (empty($productList) && empty($groupId)) { if (isset($post['lsGoodsPrice']) == false || $post['lsGoodsPrice'] <= 0) { $lsGoodsPrice = $post['lsGoodsPrice']; if (is_numeric($lsGoodsPrice) == false) { util::fail('请输入正确的金额'); } util::fail('请填写金额或选商品'); } } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $post['product'] = $productList; $return = OrderService::createFinishOrder($post, $custom, $hasPay); $transaction->commit(); //打印小票和语音播报 $id = $return->id ?? 0; $order = OrderClass::getById($id, true); if ($order->fromType == 3 || $order->fromType == 4) { //除了客服号下单和美团下单,其它情况允许打小票 } else { //前台打小票 OrderClass::onlinePrint($order); } //前台提示收款多少钱 ShopExtClass::hdGatheringReport($order); //前台提醒出示付款码 if (isset($order->status) && $order->status == 1) { if (isset($post['isCashier']) && $post['isCashier'] == 1) { ShopExtClass::pleasePayReport($order); } } //新制作单提示 $shopExt = ShopExtClass::getByCondition(['shopId' => $this->shopId], true); ShopExtClass::newWorkRemind($shopExt, $order); util::success($return); } catch (\Exception $e) { $transaction->rollBack(); Yii::error("失败原因:" . $e->getMessage()); util::fail('下单失败'); } } //下单要用到的相关信息 ssh 2019.12.6 public function actionOrderRelate() { $regionTree = RegionService::tree(); $shop = $this->shop->attributes; $freight = MerchantExtendService::getFreight($this->sjExtend); $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH'; $out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'txMapKey' => $mapKey, 'merchant' => $shop]; util::success($out); } //余额支付 ssh 2019.12.6 public function actionBalancePay() { $post = Yii::$app->request->post(); $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0; $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0; $couponId = isset($post['couponId']) ? $post['couponId'] : 0; $order = OrderService::getByOrderSn($orderSn); $userId = $this->adminId; $user = UserService::getUserInfo($userId); //验证支付密码是否正确 UserService::validPayPassword($payPassword, $user); //支付前验证订单有效性 OrderService::checkBeforePay($order); $capitalType = dict::getDict('capitalType', 'xhOrder', 'id'); $totalFee = $order['prePrice']; $sourceType = 0; $discountData = OrderService::getDiscountPrice(['price' => $totalFee, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]); $actPrice = $discountData['price']; $callbackParams = []; $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId); $balance = isset($respond['balance']) ? $respond['balance'] : 0; util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'balance' => $balance]); } //获取商城下单要用的微信支付和小程序支付参数 ssh 2019.21.3 public function actionWxPay() { ini_set('date.timezone', 'Asia/Shanghai'); $post = Yii::$app->request->post(); $couponId = isset($post['couponId']) ? $post['couponId'] : 0; $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0; $order = OrderService::getByOrderSn($orderSn); $orderId = $order['id']; //验证优惠券是否还有效 if (!empty($couponId)) { CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']); } //支付前验证订单有效性 OrderService::checkBeforePay($order); $name = isset($order['orderName']) && !empty($order['orderName']) ? $order['orderName'] : '购买商品'; $totalFee = $order['realPrice']; //小程序使用miniOpenId if (httpUtil::isMiniProgram()) { $openId = $this->user['miniOpenId']; } else { $openId = $this->user['openId']; } $capitalType = dict::getDict('capitalType', 'xhOrder', 'id'); //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调 $wxPayType = 0; if (httpUtil::isMiniProgram()) { $wxPayType = 1; } $attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType; //订单30分钟后过期 $now = time(); $expireTime = $now + 1800; $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)); $input->SetNotify_url(Yii::$app->params['hdHost'] . '/notice/wx-callback/'); $input->SetTrade_type("JSAPI"); //花卉宝代为申请的微信支付 $merchantExtend = $this->sjExtend->attributes; if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) { $input->SetSub_openid($openId); } else { $input->SetOpenid($openId); } //小程序使用miniAppId if (httpUtil::isMiniProgram()) { $merchantExtend['wxAppId'] = $merchantExtend['miniAppId']; } $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend); $tools = new \JsApiPay(); $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend); $newParams = json_decode($jsApiParameters, true); //已请求微信不能修改价格 $updateData = []; $updateData['modPrice'] = 0; if (empty($order['deadline'])) { $updateData['deadline'] = $expireTime; } OrderService::updateById($orderId, $updateData); util::success($newParams); } //快捷付款订单 public function actionFastPay() { ini_set('date.timezone', 'Asia/Shanghai'); $post = Yii::$app->request->post(); $payWay = isset($post['payWay']) ? $post['payWay'] : 0; $shopId = !empty($this->shopId) ? $this->shopId : ShopService::getDefaultShopId($this->sj); //验证门店是否有效 $shopInfo = ShopService::getById($shopId); ShopService::valid($shopInfo, $this->sjId); $post['shopId'] = $shopId; //默认门店订单 $store = isset($post['store']) ? $post['store'] : 1; $post['store'] = $store; //来源 0微信 1支付宝 2小程序 3朋友圈 4美团 $sourceType = $this->isWx ? 0 : 1; if (httpUtil::isMiniProgram()) { $sourceType = 2; } $sourceType = isset($post['sourceType']) ? $post['sourceType'] : 0; //兼容旧系统sourceType=3表示朋友圈来源 $fromType = $sourceType == 3 ? 2 : 0; $fromType = isset($post['fromType']) && !empty($post['fromType']) ? $post['fromType'] : $fromType; $post['userId'] = $this->adminId; $custom = $this->custom; $post['bookName'] = $custom['userName'] ?? ''; $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : ''; $bookMobile = empty($bookMobile) && isset($custom['mobile']) && !empty($custom['mobile']) ? $custom['mobile'] : $bookMobile; $post['bookMobile'] = $bookMobile; $prePrice = round($post['prePrice'], 2); $couponId = isset($post['couponId']) ? $post['couponId'] : 0; $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]); $actPrice = $discountData['price']; $post['discountType'] = $discountData['discountType']; $post['discountAmount'] = $discountData['discountAmount']; $post['actPrice'] = $actPrice; $post['realPrice'] = $actPrice; $post['payStyle'] = 0; $post['sjId'] = $this->sjId; $now = time(); $expireTime = $now + 300;//订单5分钟后过期 $post['createTime'] = date("Y-m-d H:i:s", $now); $post['deadline'] = $expireTime; if ($actPrice <= 0) { util::fail('请填写正确的金额'); } //微信支付订单提交不能修改价格 $post['modPrice'] = $this->isWx ? 0 : 1; $post['sourceType'] = $sourceType; $post['goodsNum'] = 1; $post['fromType'] = $fromType; $order = OrderService::addOrder($post); $orderId = $order['id']; $orderSn = $order['orderSn']; $sjId = $this->sjId; if ($payWay == 0) { $orderId = $order['id']; $name = '购买商品'; $totalFee = $actPrice; $user = UserService::getById($this->adminId); $openId = isset($user['openId']) ? $user['openId'] : 0; if (httpUtil::isMiniProgram()) { //小程序使用miniOpenId $openId = $user['miniOpenId']; } if (empty($openId)) { util::fail('没有找到客户的openId'); } $capitalType = dict::getDict('capitalType', 'xhOrder', 'id'); //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调 $wxPayType = 0; if (httpUtil::isMiniProgram()) { $wxPayType = 1; } $attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&wxPayType=' . $wxPayType; $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); //设置订单有效期5分钟 $input->SetTime_expire(date("YmdHis", $expireTime)); $input->SetNotify_url(Yii::$app->params['hdHost'] . '/notice/wx-callback/'); $input->SetTrade_type("JSAPI"); //花卉宝代为申请的微信支付 $merchantExtend = $this->sjExtend->attributes; if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) { $input->SetSub_openid($openId); } else { $input->SetOpenid($openId); } //小程序使用miniAppId if (httpUtil::isMiniProgram()) { $merchantExtend['wxAppId'] = $merchantExtend['miniAppId']; } Yii::info('支付发起使用小程序信息' . json_encode($merchantExtend)); $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend); $tools = new \JsApiPay(); $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend); $newParams = json_decode($jsApiParameters, true); $newParams['orderId'] = $orderId; util::success($newParams); } elseif ($payWay == 1) { $extend = MerchantExtendService::getBySjId($sjId); if (isset($extend['alipayInit']) == false || $extend['alipayInit'] == 0) { util::fail('支付宝付款即将开通...'); } $config = [ //应用ID,您的APPID。 'app_id' => $extend['alipayPId'], //商户私钥,您的原始格式RSA私钥 'merchant_private_key' => $extend['alipayKey'], //异步通知地址 'notify_url' => Yii::$app->params['hdHost'] . "/notice/ali-callback", //同步跳转 'return_url' => "", //编码格式 'charset' => "UTF-8", //签名方式 'sign_type' => "RSA2", //支付宝网关 'gatewayUrl' => "https://openapi.alipay.com/gateway.do", //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。 'alipay_public_key' => $extend['alipayPublicKey'], ]; Yii::info(json_encode($config) . ' aplipay config'); $alipayWap = Yii::getAlias("@vendor/alipayWap"); require_once($alipayWap . '/wappay/service/AlipayTradeService.php'); require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php'); $totalFee = $order['realPrice']; $out_trade_no = $orderSn;//商户订单号,商户网站订单系统中唯一订单号,必填 $subject = '购买商品';//订单名称,必填 $total_amount = $totalFee;//付款金额,必填 $body = '';//商品描述,可空 $timeout_express = "1m";//超时时间 $capitalType = dict::getDict('capitalType', 'xhOrder', 'id'); $passBackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&sjId=' . $sjId;//将流水类型、优惠卷传过去 $passBackParams = urlencode($passBackParams); $payRequestBuilder = new \AlipayTradeWapPayContentBuilder(); $payRequestBuilder->setBody($body); $payRequestBuilder->setSubject($subject); $payRequestBuilder->setOutTradeNo($out_trade_no); $payRequestBuilder->setTotalAmount($total_amount); $payRequestBuilder->setTimeExpress($timeout_express); //在异步通知时将该参数原样返回 $payRequestBuilder->setPassbackParams($passBackParams); //同步通知 $returnUrl = Yii::$app->params['mallDomain'] . "/#/pages/callback/success?account={$sjId}&shopId={$shopId}&orderSn={$orderSn}&totalPrice={$totalFee}&pageStatus=3&payDiscountPrice=0&payDiscountType=0"; //异步通知 $notifyUrl = Yii::$app->params['mallHost'] . "/notice/ali-callback"; $payResponse = new \AlipayTradeService($config); $result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl); //直接将支付宝的html返回给前端 echo $result; } elseif ($payWay == 2) { //余额支付,验证支付密码是否正确 $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0; $user = UserService::getUserInfo($this->adminId); UserService::validPayPassword($payPassword, $user); $capitalType = dict::getDict('capitalType', 'xhOrder', 'id'); $callbackParams = []; $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId); $balance = isset($respond['balance']) ? $respond['balance'] : 0; util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $orderId, 'balance' => $balance]); } else { util::fail('无效的支付方式'); } } //订单评价 public function actionComment() { $post = Yii::$app->request->post(); $id = $post['id']; $order = OrderService::getById($id); OrderService::valid($order, $this->mainId); if ($order['grade'] > 0) { util::fail('您已经评过了'); } OrderService::comment($post); util::complete('提交成功'); } //订单详情 ssh 2019.12.16 public function actionDetail() { $id = Yii::$app->request->get('id', 0); $detail = OrderClass::getFullInfo($id); OrderService::valid($detail, $this->mainId); util::success($detail); } public function actionList() { $get = Yii::$app->request->get(); $search = isset($get['search']) ? $get['search'] : ''; $shopId = $this->shopId ?? 0; if (empty($shopId)) { //没有登录不显示数据 util::success(['list' => [], 'moreData' => 0, 'shop' => [], 'totalNum' => 0, 'totalPage' => 0]); } $where = []; $where['shopId'] = $shopId; $status = $get['status'] ?? 0; if (!empty($status)) { $where['status'] = $get['status']; } if (isset($get['shopAdminId']) && !empty($get['shopAdminId'])) { $where['shopAdminId'] = $get['shopAdminId']; } if (isset($get['searchText']) && !empty($get['searchText'])) { if (is_numeric($get['searchText'])) { $where['sendNum'] = $get['searchText']; } else { $where['bookName'] = $get['searchText']; } } if (!empty($search)) { if (stringUtil::isMobile($search)) { $where['bookMobile'] = $search; } else { $where['orderSn'] = $search; } } $searchTime = $get['searchTime'] ?? ''; if (!empty($searchTime)) { $startTime = $get['startTime'] ?? ''; $endTime = $get['endTime'] ?? ''; $period = dateUtil::formatTime($searchTime, $startTime, $endTime); $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]]; } $list = OrderService::getOrderList($where); $list['shop'] = $this->shop->attributes ?? []; util::success($list); } //订单归类 ssh 2019.12.17 public function actionClassify() { $post = Yii::$app->request->post(); $id = isset($post['id']) ? $post['id'] : 0; $order = OrderService::getById($id); OrderService::valid($order, $this->mainId); $categoryId = isset($post['categoryId']) ? $post['categoryId'] : $post['categoryId']; $usageId = isset($post['usageId']) ? $post['usageId'] : $post['usageId']; OrderService::classify($id, $categoryId, $usageId); util::complete(); } //更新配送单 ssh 2019.12.17 public function actionUpdateSheet() { $post = Yii::$app->request->post(); $id = isset($post['id']) ? $post['id'] : 0; unset($post['id']); $order = OrderService::getById($id); OrderService::valid($order, $this->mainId); OrderService::updateSheet($order, $post); util::complete('提交成功'); } //商家收款与发货 ssh 2019.12.18 public function actionGathering() { $post = Yii::$app->request->post(); $price = isset($post['price']) && is_numeric($post['price']) ? $post['price'] : 0; $payWay = isset($post['payWay']) && is_numeric($post['payWay']) ? $post['payWay'] : 0; $userId = isset($post['userId']) ? $post['userId'] : 0; $userInfo = UserService::getById($userId); if (empty($userInfo) || $userInfo['sjId'] != $this->sjId) { util::fail('您选择的客户无效'); } if ($price <= 0) { util::fail('请输入金额'); } $post['prePrice'] = $price; $post['actPrice'] = $price; $post['payWay'] = $payWay; $post['sourceType'] = 1; $post['userId'] = $userId; $post['goodsNum'] = 1; $post['orderName'] = '商品'; $shopId = MerchantService::getDefaultShopId($this->sj); $post['shopId'] = $shopId; $order = OrderService::addOrder($post); $id = $order['id']; $orderSn = $order['orderSn']; //流水类型列表 $capitalType = dict::getDict('capitalType', 'xhOrder', 'id'); $callbackParams = []; switch ($payWay) { case 0: xhPayToolService::wxPay($callbackParams, $orderSn, $price, $capitalType, 0); break; case 1: xhPayToolService::alipay($callbackParams, $orderSn, $price, $capitalType, 0, []); break; case 2: xhPayToolService::balancePay($callbackParams, $orderSn, $price, $capitalType, 0); break; default: util::fail('无效支付方式'); } util::success($order); } //免发货管理 ssh 2020.1.6 public function actionWithoutSend() { $id = Yii::$app->request->get('id'); $order = OrderService::getById($id); OrderService::valid($order, $this->mainId); //配送流程变更 $currentFlow = OrderSendClass::withoutSend($order); util::success(['currentFlow' => $currentFlow]); } //修改价格 ssh 2020.1.6 public function actionUpdatePrice() { $id = Yii::$app->request->get('id'); $price = Yii::$app->request->get('price', 1); $order = OrderService::getById($id); OrderService::valid($order, $this->mainId); if (isset($order['modPrice']) && $order['modPrice'] == 0) { util::fail('已发起支付,不能修改价格'); } OrderService::updateById($id, ['actPrice' => $price]); util::complete('修改成功'); } //配送单 ssh 2020.2.29 public function actionGetDeliverDetail() { $id = Yii::$app->request->get('id', 0); $order = OrderService::getById($id); OrderService::valid($order, $this->mainId); $reachDate = isset($order['reachDate']) && !empty($order['reachDate']) ? $order['reachDate'] : ''; $reachPeriodId = $order['reachPeriod']; $reachPeriodArr = [0 => '上午', 1 => '下午', 2 => '晚上']; $reachPeriod = isset($reachPeriodArr[$reachPeriodId]) ? $reachPeriodArr[$reachPeriodId] : ''; $bookName = isset($order['bookName']) ? $order['bookName'] : ''; $bookMobile = isset($order['bookMobile']) ? $order['bookMobile'] : ''; if (isset($order['anonymity']) && $order['anonymity'] == 1) { $bookName = '--'; $bookMobile = '--'; } $data = [ 'reachDate' => $reachDate . ' ' . $reachPeriod, 'orderSn' => $order['orderSn'], 'receiveUserName' => $order['receiveUserName'], 'receiveMobile' => $order['receiveMobile'], 'fullAddress' => $order['fullAddress'] . "(" . $order['showAddress'] . ")", 'cardInfo' => $order['cardInfo'], 'bookMobile' => $bookMobile, 'bookName' => $bookName, 'remark' => $order['remark'], 'sendNum' => $order['sendNum'], 'telephone' => 18030142050, 'printTime' => '', 'img' => '', ]; util::success($data); } //运费计算 lqh 2021.4.12 暂反回固定 public function actionFreight() { util::success(['sedCost' => 10]); } }