isEmpty()){ //判断是否存在规格-获取重量 $specs = $fengsuSku::getSpecsIdByShopId($shops->shop_id, $item['disInnerOrderGoodsViewList'][0]['shopSkuId']); if(!$specs->isEmpty()) { //根据规格重量获取,加收价格 $weight = $productConfig::getWeight($specs->spec_id); $status = 3; if($weight){ $other_price = self::getRemoteAreaFee($item['expressCompany'], $weight, $item['receiverState'], $item['receiverCity']); //获取包装箱 $box = $customerSpec::getBoxId($shops->customer_id, $specs->variety_id, $specs->spec_id); $shopDelivery::create([ 'customer_id' => $shops->customer_id, 'shop_id' => $shops->id, 'plat_id' => $shops->platform, 'variety_id' => $specs->variety_id, 'spec_id' => $specs->spec_id, 'spec_name' => $specs->spec_name, 'box_id' => $specs->box_id??0, 'box_name' => $box->box_name??'', 'variety_name' => $box->variety_name, 'num' => $item['disInnerOrderGoodsViewList'][0]['itemCount'], 'weigh' => $weight, 'price' => $box->price??0, 'total_price' => bcmul($box->price, (string)$item['disInnerOrderGoodsViewList'][0]['itemCount'], 2), 'company_name' => $item['expressCompany'], 'waybill_no' => ltrim($item['trackNo'], '@'), 'region' => $item['receiverState'].' '.$item['receiverCity'], 'other_price' => $other_price, 'ship_date' => substr($item['deliveryDate'], 0, 10), ]); } }else{ $status = 2; } } return $status; } /** 编辑规格-加收价格 * @param array $item * @return int */ public static function setAdditionalPrice(object $fengsuSku,object $shopList, object $productConfig, object $shopDelivery, object $customerSpec, string $shop_id,$sku_id, $variety_id, $spec_id, string $spec_name, object $item):bool { //判断是否存在规格-获取重量 $specs = $fengsuSku::getSpecsIdByShopId($shop_id, $sku_id); //判断是否存在店铺 $shops = $shopList::getSpecsIdByShopId($shop_id); //根据规格重量获取,加收价格 $weight = $productConfig::getWeight((int)$spec_id); $other_price = self::getRemoteAreaFee($item['company_name'], $weight??0, $item['province'], $item['city']); //获取包装箱 $box = $customerSpec::getBoxId($shops->customer_id, (int)$variety_id, (int)$spec_id); $shopDelivery::create([ 'customer_id' => $shops->customer_id, 'shop_id' => $shops->id, 'plat_id' => $shops->platform, 'variety_id' => $variety_id, 'spec_id' => $spec_id, 'spec_name' => $specs->spec_name, 'box_id' => $box->id??0, 'box_name' => $box->box_name??'', 'variety_name' => $box->variety_name, 'num' => $item['num'], 'weigh' => $weight??0, 'price' => $box->price??0, 'total_price' => bcmul((string)$box->price, (string)$item['num'], 2), 'company_name' => $item['company_name'], 'waybill_no' => $item['waybill_no'], 'region' => $item['province'].' '.$item['city'], 'other_price' => $other_price, 'ship_date' => substr($item['consign_time'], 0, 10), ]); return true; } /** * 获取偏远地区加收费用 * @param string $express 快递公司名称 * @param string $area 省份 * @param float $weight 重量 * @param string $city 城市 * @return float */ protected static function getRemoteAreaFee(string $express, string $weight, string $area, string $city = ''){ $remote_area = config('app.remote_area'); $fee = 0; if($express == '顺丰速运'){ if(in_array($area, $remote_area[1])) { if($weight >= 3.5) $fee = 5; if($weight >= 4.5) $fee = 6; }; }else{ //普通(广东省-深圳) -浙江-舟山 if(in_array($area, $remote_area[0])) $fee = 1.5; if($area == '广东省' && $city == '深圳市') $fee = 1.5; if($area == '浙江省' && $city == '舟山市') $fee = 1.5; } return $fee; } //防止重复记录,订单号+快递单号 public static function prevent_duplicate_additions($oid,$waybill_no){ $importList=new ImportList(); $where = [ 'order_id' => ['=', $oid], 'waybill_no' => ['=', $waybill_no] ]; $result = $importList->where($where)->count(); return $result=$result>0?true:false; } }