FengsuService.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * ----------------------------------------------------------------------------
  4. * 行到水穷处,坐看云起时
  5. * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
  6. * ----------------------------------------------------------------------------
  7. * Author: 老成
  8. * email:85556713@qq.com
  9. */
  10. declare(strict_types=1);
  11. namespace app\admin\service;
  12. use app\admin\service\JuShuiTanService;
  13. class FengsuService {
  14. /** 加收价格
  15. * 1.先判断店铺
  16. * 2.在判断店铺下面的规格
  17. * @param array $item
  18. * @return int
  19. */
  20. public static function getAdditionalPrice(object $shopList, object $sku, object $productConfig, object $shopDelivery, object $customerSpec, array $item)
  21. {
  22. // dump('店铺0');
  23. $status = 1;
  24. $shopDelivery=[];
  25. //判断是否存在店铺
  26. $shops = $shopList::getSpecsIdByShopId($item['shopId']);
  27. // dump('店铺00');
  28. if(!$shops->isEmpty()){
  29. // dump('店铺1');
  30. //判断是否存在规格-获取重量
  31. $specs = $sku::getSpecsIdByShopId($shops->shop_id, $item['tradeOrderPrintVos'][0]['skuId']);
  32. if(!$specs->isEmpty()) {
  33. // dump('店铺2');
  34. //根据规格重量获取,加收价格
  35. $weight = $productConfig::getWeight($specs->spec_id);
  36. $status = 3;
  37. if($weight){
  38. // dump('店铺3');
  39. $other_price = JuShuiTanService::getRemoteAreaFee($item['tradeOrderPrintVos'][0]['companyName'], $weight, $item['receiverProvince'], $item['receiverCity']);
  40. // 保温加收价格
  41. $getPackSpecsFee=JuShuiTanService::getPackSpecsFee($sku,$item['shopId'], $item['tradeOrderPrintVos'][0]['skuId'],$item['receiverProvince']);
  42. $pack_specs=strval($getPackSpecsFee['surcharge_money']);
  43. // $other_price=(string)$other_price;
  44. // $other_price=strval($other_price);
  45. // $other_price=bcadd($other_price,$pack_specs, 2);
  46. //获取包装箱
  47. $box = $customerSpec::getBoxId($shops->customer_id, $specs->variety_id, $specs->spec_id);
  48. // $shopDelivery::create([
  49. // 'customer_id' => $shops->customer_id,
  50. // 'shop_id' => $shops->id,
  51. // 'plat_id' => $shops->platform,
  52. // 'variety_id' => $specs->variety_id,
  53. // 'spec_id' => $specs->spec_id,
  54. // 'spec_name' => $specs->spec_name,
  55. // 'box_id' => $box->id??0,
  56. // 'box_name' => $box->box_name??'',
  57. // 'variety_name' => $box->variety_name,
  58. // 'num' => $item['tradeOrderPrintVos'][0]['total'],
  59. // 'weigh' => $weight,
  60. // 'price' => $box->price??0,
  61. // 'total_price' => bcmul($box->price, (string)$item['tradeOrderPrintVos'][0]['total'], 2),
  62. // 'company_name' => $item['tradeOrderPrintVos'][0]['companyName'],
  63. // 'waybill_no' => $item['waybillNo'],
  64. // 'region' => $item['receiverProvince'].' '.$item['receiverCity'],
  65. // 'other_price' => $other_price,
  66. // 'ship_date' => substr($item['consignTime'], 0, 10),
  67. // ]);
  68. $shopDelivery=[
  69. 'customer_id' => $shops->customer_id,
  70. 'shop_id' => $shops->id,
  71. 'plat_id' => $shops->platform,
  72. 'variety_id' => $specs->variety_id,
  73. 'spec_id' => $specs->spec_id,
  74. 'spec_name' => $specs->spec_name,
  75. 'box_id' => $box->id??0,
  76. 'box_name' => $box->box_name??'',
  77. 'variety_name' => $box->variety_name,
  78. 'num' => $item['tradeOrderPrintVos'][0]['total'],
  79. 'weigh' => $weight,
  80. 'price' => $box->price??0,
  81. 'total_price' => bcmul((string)$box->price, (string)$item['tradeOrderPrintVos'][0]['total'], 2),
  82. 'company_name' => $item['tradeOrderPrintVos'][0]['companyName'],
  83. 'waybill_no' => $item['waybillNo'],
  84. 'region' => $item['receiverProvince'].' '.$item['receiverCity'],
  85. 'other_price' => $other_price,
  86. 'ship_date' => substr($item['consignTime'], 0, 10),
  87. 'incubator' => $getPackSpecsFee['pack_specs_type'],
  88. 'insulation_money' => $getPackSpecsFee['surcharge_money'],
  89. 'labor_cost_money' => $getPackSpecsFee['data']['labor_cost_money']
  90. ];
  91. }
  92. }else{
  93. $status = 2;
  94. }
  95. }
  96. // return $status;
  97. $data=[
  98. 'shopDelivery'=>$shopDelivery,
  99. 'status'=>$status
  100. ];
  101. return $data;
  102. }
  103. }