|
|
@@ -20,15 +20,17 @@ class JuShuiTanService {
|
|
|
* @param array $item
|
|
|
* @return int
|
|
|
*/
|
|
|
- public static function getAdditionalPrice(object $shopList, object $fengsuSku, object $productConfig, object $shopDelivery, object $customerSpec, array $item):int
|
|
|
+ public static function getAdditionalPrice(object $shopList, object $sku, object $productConfig, object $shopDelivery, object $customerSpec, array $item)
|
|
|
{
|
|
|
$status = 1;
|
|
|
+ $shopDelivery=[];
|
|
|
+
|
|
|
//判断是否存在店铺
|
|
|
$shops = $shopList::getSpecsIdByShopId($item['shopId']);
|
|
|
if(!$shops->isEmpty()){
|
|
|
|
|
|
//判断是否存在规格-获取重量
|
|
|
- $specs = $fengsuSku::getSpecsIdByShopId($shops->shop_id, $item['disInnerOrderGoodsViewList'][0]['shopSkuId']);
|
|
|
+ $specs = $sku::getSpecsIdByShopId($shops->shop_id, $item['disInnerOrderGoodsViewList'][0]['shopSkuId']);
|
|
|
|
|
|
if(!$specs->isEmpty()) {
|
|
|
|
|
|
@@ -37,9 +39,38 @@ class JuShuiTanService {
|
|
|
$status = 3;
|
|
|
if($weight){
|
|
|
$other_price = self::getRemoteAreaFee($item['expressCompany'], $weight, $item['receiverState'], $item['receiverCity']);
|
|
|
+
|
|
|
+ // 保温加收价格
|
|
|
+ $getPackSpecsFee=self::getPackSpecsFee($sku,$item['shopId'], $item['disInnerOrderGoodsViewList'][0]['shopSkuId'],$item['receiverState']);
|
|
|
+ $pack_specs=strval($getPackSpecsFee['surcharge_money']);
|
|
|
+ $other_price=(string)$other_price;
|
|
|
+ $other_price=strval($other_price);
|
|
|
+ $other_price=bcadd($other_price,$pack_specs, 2);
|
|
|
+
|
|
|
//获取包装箱
|
|
|
$box = $customerSpec::getBoxId($shops->customer_id, $specs->variety_id, $specs->spec_id);
|
|
|
- $shopDelivery::create([
|
|
|
+ // $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),
|
|
|
+ // 'incubator' => $getPackSpecsFee['pack_specs_type']
|
|
|
+ // ]);
|
|
|
+ $shopDelivery=[
|
|
|
'customer_id' => $shops->customer_id,
|
|
|
'shop_id' => $shops->id,
|
|
|
'plat_id' => $shops->platform,
|
|
|
@@ -52,19 +83,25 @@ class JuShuiTanService {
|
|
|
'num' => $item['disInnerOrderGoodsViewList'][0]['itemCount'],
|
|
|
'weigh' => $weight,
|
|
|
'price' => $box->price??0,
|
|
|
- 'total_price' => bcmul($box->price, (string)$item['disInnerOrderGoodsViewList'][0]['itemCount'], 2),
|
|
|
+ 'total_price' => bcmul((string)$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),
|
|
|
- ]);
|
|
|
+ 'incubator' => $getPackSpecsFee['pack_specs_type']
|
|
|
+ ];
|
|
|
}
|
|
|
}else{
|
|
|
$status = 2;
|
|
|
}
|
|
|
}
|
|
|
- return $status;
|
|
|
+ $data=[
|
|
|
+ 'shopDelivery'=>$shopDelivery,
|
|
|
+ 'status'=>$status
|
|
|
+ ];
|
|
|
+ return $data;
|
|
|
+ // return $status;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -72,21 +109,52 @@ class JuShuiTanService {
|
|
|
* @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
|
|
|
+ public static function setAdditionalPrice(object $sku,object $shopList, object $productConfig, object $shopDelivery, object $customerSpec, string $shop_id,$sku_id, $variety_id, $spec_id, string $spec_name, object $item)
|
|
|
{
|
|
|
//判断是否存在规格-获取重量
|
|
|
- $specs = $fengsuSku::getSpecsIdByShopId($shop_id, $sku_id);
|
|
|
+ $specs = $sku::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']);
|
|
|
+
|
|
|
+ $other_price =self::getRemoteAreaFee($item['company_name'], $weight??0, $item['province'], $item['city']);
|
|
|
+
|
|
|
+ // 保温加收价格
|
|
|
+ $getPackSpecsFee=self::getPackSpecsFee($sku,$shop_id, $sku_id,$item['province']);
|
|
|
+ $pack_specs=strval($getPackSpecsFee['surcharge_money']);
|
|
|
+ $other_price=(string)$other_price;
|
|
|
+ $other_price=strval($other_price);
|
|
|
+ $other_price=bcadd($other_price,$pack_specs, 2);
|
|
|
//获取包装箱
|
|
|
$box = $customerSpec::getBoxId($shops->customer_id, (int)$variety_id, (int)$spec_id);
|
|
|
-
|
|
|
- $shopDelivery::create([
|
|
|
+ // $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),
|
|
|
+ // 'incubator' => $getPackSpecsFee['pack_specs_type']
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // ]);
|
|
|
+ $shopDelivery=[
|
|
|
'customer_id' => $shops->customer_id,
|
|
|
'shop_id' => $shops->id,
|
|
|
'plat_id' => $shops->platform,
|
|
|
@@ -105,8 +173,16 @@ class JuShuiTanService {
|
|
|
'region' => $item['province'].' '.$item['city'],
|
|
|
'other_price' => $other_price,
|
|
|
'ship_date' => substr($item['consign_time'], 0, 10),
|
|
|
- ]);
|
|
|
- return true;
|
|
|
+ 'incubator' => $getPackSpecsFee['pack_specs_type']
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ];
|
|
|
+ $data=[
|
|
|
+ 'shopDelivery'=>$shopDelivery,
|
|
|
+ 'getPackSpecsFee'=>$getPackSpecsFee
|
|
|
+ ];
|
|
|
+ return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -117,10 +193,13 @@ class JuShuiTanService {
|
|
|
* @param string $city 城市
|
|
|
* @return float
|
|
|
*/
|
|
|
- protected static function getRemoteAreaFee(string $express, string $weight, string $area, string $city = ''){
|
|
|
- $remote_area = config('app.remote_area');
|
|
|
+ public static function getRemoteAreaFee(string $express, string $weight, string $area, string $city = ''){
|
|
|
+ // $remote_area = config('app.remote_area');
|
|
|
+ $remote_area=[];
|
|
|
+ $remote_area[0]=site_config("addonsd.remote_area_0");
|
|
|
+ $remote_area[1]=site_config("addonsd.remote_area_1");
|
|
|
$fee = 0;
|
|
|
- if($express == '顺丰速运'){
|
|
|
+ if($express == '顺丰快递'||$express=='顺丰速运'){
|
|
|
if(in_array($area, $remote_area[1])) {
|
|
|
if($weight >= 3.5) $fee = 5;
|
|
|
if($weight >= 4.5) $fee = 6;
|
|
|
@@ -134,14 +213,65 @@ class JuShuiTanService {
|
|
|
return $fee;
|
|
|
}
|
|
|
//防止重复记录,订单号+快递单号
|
|
|
- public static function prevent_duplicate_additions($oid,$waybill_no){
|
|
|
+ public static function prevent_duplicate_additions($sku_id,$waybill_no){
|
|
|
$importList=new ImportList();
|
|
|
$where = [
|
|
|
- 'order_id' => ['=', $oid],
|
|
|
+ 'sku_id' => ['=', $sku_id],
|
|
|
'waybill_no' => ['=', $waybill_no]
|
|
|
];
|
|
|
$result = $importList->where($where)->count();
|
|
|
return $result=$result>0?true:false;
|
|
|
}
|
|
|
-
|
|
|
+ // 保温加收区域设置,加收金额
|
|
|
+ public static function getPackSpecsFee($sku,$shop_id,$sku_id,$province){
|
|
|
+ $res=[
|
|
|
+ 'data'=>[
|
|
|
+ 'id'=>0,
|
|
|
+ 'labor_cost_money'=>0,
|
|
|
+ ],
|
|
|
+ 'one_surcharge_money'=>0,
|
|
|
+ 'two_surcharge_money'=>0,
|
|
|
+ 'pack_specs_type'=>0,
|
|
|
+ 'surcharge_money'=>0
|
|
|
+ ];
|
|
|
+ $pack_specs_one_region=site_config("addonsd.pack_specs_one_region");
|
|
|
+ $pack_specs_two_region=site_config("addonsd.pack_specs_two_region");
|
|
|
+ $pack_specs_one_type=in_array($province,$pack_specs_one_region);
|
|
|
+ $pack_specs_two_type=in_array($province,$pack_specs_two_region);
|
|
|
+ $pack_specs_type=0;
|
|
|
+ if($pack_specs_one_type){
|
|
|
+ $pack_specs_type=1;
|
|
|
+ }else if($pack_specs_two_type){
|
|
|
+ $pack_specs_type=2;
|
|
|
+ }
|
|
|
+ // if(empty($pack_specs_type))return $res;
|
|
|
+ $result=$sku::getPackSpecs($shop_id, $sku_id);
|
|
|
+ if(empty($result)) return $res;
|
|
|
+ $surcharge_money=0;
|
|
|
+ $one_surcharge_money=0;
|
|
|
+ $two_surcharge_money=0;
|
|
|
+ switch ($pack_specs_type) {
|
|
|
+ case 1:
|
|
|
+ $surcharge_money=$result->one_surcharge_money;
|
|
|
+ $one_surcharge_money=$surcharge_money;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ $surcharge_money=$result->two_surcharge_money;
|
|
|
+ $two_surcharge_money=$surcharge_money;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $surcharge_money=0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $res=[
|
|
|
+ 'data'=>$result,
|
|
|
+ 'pack_specs_type'=>$pack_specs_type,
|
|
|
+ 'one_surcharge_money'=>$one_surcharge_money,
|
|
|
+ 'two_surcharge_money'=>$two_surcharge_money,
|
|
|
+ 'surcharge_money'=>$surcharge_money
|
|
|
+
|
|
|
+ ];
|
|
|
+
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
}
|