Model_logic_weight.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * 此处是设定erp重量的标准 以后获取重量都尽量通过这去获取重量 以前的代码还是通过以前的方案
  4. */
  5. class Model_logic_weight extends Lin_Model {
  6. //切记要修改token_120的token真正的token!!!!
  7. function __construct(){
  8. parent::__construct();
  9. $this->load->_model('Model_weight','weight');
  10. }
  11. /**
  12. * $type erp类目 如 126 127 128
  13. */
  14. public function getWeightByFeature($type,$features){
  15. if(empty($type)){
  16. return 0;
  17. }
  18. $sku = [];
  19. if($type == 126){
  20. return 100;
  21. }
  22. //类目 蕾丝尺寸 长度
  23. if($type == 127){
  24. //发块
  25. $flag = true;
  26. foreach($features as $v){
  27. if($v['classid'] == 26){
  28. $flag = false;
  29. }
  30. }
  31. if($flag){
  32. //蕾丝尺寸1
  33. $sku = ['16'=>127,'25'=>0,'14'=>0];
  34. }else{
  35. //蕾丝尺寸2
  36. $sku = ['16'=>127,'26'=>0,'14'=>0];
  37. }
  38. }
  39. //类目 头套类型 尺寸 密度
  40. if($type == 128){
  41. //头套类型
  42. $sku = ['16'=>128,'18'=>0,'14'=>0,'10'=>0];
  43. }
  44. //类目 尺寸
  45. if($type == 130){
  46. //接发类型
  47. $sku = ['16'=>130,'33'=>0,'14'=>0];
  48. }
  49. foreach($features as $k => $v){
  50. if(isset($sku[$v['classid']])){
  51. $sku[$v['classid']] = $v['id'];
  52. }
  53. }
  54. $sku_str = implode("-",$sku);
  55. var_dump($sku_str);
  56. $weight_info = $this->weight->get_features($sku_str);
  57. if(empty($weight_info)){
  58. return 0;
  59. }else{
  60. return $weight_info['weight'];
  61. }
  62. }
  63. }