request->get(); $status = $get['status'] ?? 0; if (!empty($status)) { $where['status'] = $status; } $where['merchantId'] = $this->merchantId; if (isset($get['shopId'])) { $shopId = $get['shopId'] ?? 0; if (!empty($shopId)) { $where['shopId'] = $this->shopId; } } else { $where['shopId'] = $this->shopId; } $data = OrderClass::getOrderList($where); util::success($data); } //商城下单操作 shish 2021.1.14 public function actionCreateOrder() { $post = Yii::$app->request->post(); $adminId = $this->adminId; $shopId = $this->shopId; if (!empty($shopId)) { //供货商端 员工 开单 $post['customId'] = $post['customId'] ?? 0; $post['adminId'] = $adminId; $post['userId'] = 0; } else { //供货商端 客户 开单 $post['userId'] = $adminId; $post['adminId'] = 0; $post['customId'] = CustomClass::addCustom(); } $post['payWay'] = $this->isWx == true ? 0 : 1; $post['merchantId'] = $this->merchantId; $post['shopId'] = 0; $post['deadline'] = time() + 1800;//订单30分钟后过期 $post['fromType'] = 1;//商城 $post['prePrice'] = 0.01; $post['actPrice'] = 0.01; $post['sendSide'] = $post['sendSide'] ?? 0; $productJson = $post['product'] ?? ''; if (empty($productJson)) { util::fail('请选择花材'); } $productList = json_decode($productJson, true); if (empty($productList)) { util::fail('请选择花材'); } $productIds = array_column($productList, 'productId'); ProductClass::valid($productIds, $this->merchantId); $post['product'] = $productList; $order = OrderClass::addOrder($post); $orderSn = $order['orderSn'] ?? ''; $orderId = $order['id'] ?? 0; util::success([ 'orderId' => $orderId, 'orderSn' => $orderSn, 'totalPrice' => 0.01, 'sendType' => '快递送', 'sendTime' => '15:00', 'qrCode' => Yii::$app->params['imgHost'] . '/hhb_small.png', ]); } //延期支付 shish 2021.1.19 public function actionDebt() { $get = Yii::$app->request->get(); util::complete(); } //已经支付 public function actionHasPay() { $get = Yii::$app->request->get(); util::complete(); } //获取商城下单要用的微信支付和小程序支付参数 shish 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 = OrderClass::getByOrderSn($orderSn); $orderId = $order['id']; //支付前验证订单有效性 OrderClass::valid($order, $this->adminId); $name = isset($order['orderName']) && !empty($order['orderName']) ? $order['orderName'] : '购买商品'; $totalFee = $order['actPrice']; //小程序使用miniOpenId if (httpUtil::isMiniProgram()) { $openId = $this->user['miniOpenId']; } else { $openId = $this->user['openId']; } $typeList = configDict::getConfig('capitalType'); $capitalType = $typeList['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['mallHost'] . '/notice/wx-callback/'); $input->SetTrade_type("JSAPI"); //花卉宝代为申请的微信支付 $merchantExtend = $this->merchantExtend; if ($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); } //获取订单详情 shish 2021.1.21 public function actionDetail() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $info = OrderClass::getOrderInfo($id, true, true); OrderClass::valid($info, $this->shopId); util::success($info); } //重选花材 shish 2021.1.22 public function actionChooseProduct() { $post = Yii::$app->request->post(); $id = $post['id'] ?? 0; $product = $post['product'] ?? '[]'; $product = json_decode($product, true); //检查花材是否都是同家门店的 ProductClass::valid($product, $this->shopId); $info = OrderClass::getOrderInfo($id); OrderClass::valid($info, $this->shopId); //添加修改花材 OrderItemService::replace($info, $product); util::complete(); } //自取 shish 2021.1.22 public function actionSelfGet() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; util::complete(); } }