request->post(); $id = $post['id'] ?? 0; $weight = $post['weight'] ?? 0; if (empty($weight) || $weight <= 0) { util::fail('请填写重量'); } $length = $post['length'] ? trim($post['length']) : 0; if (!is_numeric($length) || $length <= 0) { util::fail('请填写长度'); } $width = $post['width'] ? trim($post['width']) : 0; if (!is_numeric($width) || $width <= 0) { util::fail('请填写宽度'); } $height = $post['height'] ? trim($post['height']) : 0; if (!is_numeric($height) || $height <= 0) { util::fail('请填写高度'); } $packageNum = $post['packageNum'] ? trim($post['packageNum']) : 0; if (!is_numeric($packageNum) || $packageNum <= 0) { util::fail('请填写包裹数量'); } $order = OrderClass::getById($id, true); if (empty($order)) { util::fail('没有找到订单'); } if ($order->mainId != $this->mainId) { util::fail('不是你的订单'); } $orderSn = $order->orderSn ?? ''; $customId = $order->customId ?? 0; $custom = CustomClass::getById($customId, true); if (empty($custom)) { util::fail('没有找到客户'); } //要先去后台绑定,这里填写才有用,mainId对应月结账号 $bizIdMap = [ //长春花路鲜花, '36707' => '4212960899', //龙岩花掌柜 '50' => '5925274162', ]; $mainId = $this->mainId; if (getenv('YII_ENV') == 'production') { $bizId = $bizIdMap[$mainId] ?? 0; if (empty($bizId)) { util::fail('没有找到月结账号'); } //暂时只支持顺丰 $deliveryId = 'SF'; $serviceType = 0; $serviceName = '标准快递'; } else { $deliveryId = 'TEST'; $bizId = 'test_biz_id'; $serviceType = 1; $serviceName = 'test_service_name'; } $admin = $this->admin; $openId = $admin->ghsMiniOpenId ?? ''; if (empty($openId)) { util::fail('请用小程序发单'); } $shop = $this->shop; $shopName = $shop->shopName; $sjName = $shop->merchantName; $senderName = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName; $senderMobile = !empty($shop->telephone) ? $shop->telephone : $shop->mobile; $senderProvince = $shop->province; $senderCity = $shop->city; $senderAddress = $shop->address; if (empty($senderAddress)) { util::fail('你的门店地址还没有设置'); } $receiverName = $custom->name; $receiverMobile = $custom->mobile; $receiverProvince = $custom->province; $receiverCity = $custom->city; $receiverAddress = $custom->address; $goodsName = '鲜花花材'; $customRemark = '鲜花花材,编号:' . $order->sendNum; $goodsCount = ceil($order->itemNum);; $shopImgUrl = imgUtil::groupImg('logo4.png') . "?x-oss-process=image/resize,m_fill,h_80,w_80"; $params = [ 'bizId' => $bizId,// 快递公司客户编码或月结账号 'openId' => $openId, 'senderName' => $senderName, 'senderMobile' => $senderMobile, 'senderProvince' => $senderProvince, 'senderCity' => $senderCity, 'senderAddress' => $senderAddress, 'receiverName' => $receiverName, 'receiverMobile' => $receiverMobile, 'receiverProvince' => $receiverProvince, 'receiverCity' => $receiverCity, 'receiverAddress' => $receiverAddress, 'goodsCount' => $goodsCount, 'goodsName' => $goodsName, 'customRemark' => $customRemark, 'weight' => $weight, 'length' => $length, 'width' => $width, 'height' => $height, 'packageNum' => $packageNum, 'deliveryId' => $deliveryId, 'serviceType' => $serviceType, 'serviceName' => $serviceName, 'orderSn' => $orderSn, 'shopImgUrl' => $shopImgUrl, ]; ExpressClass::addWayBill($params); } }