goodsModel.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. class flow_goodsClassModel extends flowModel
  3. {
  4. protected function flowchangedata(){
  5. $this->rs['typeid'] = m('goods')->gettypename($this->rs['typeid']);
  6. }
  7. //导入数据的测试显示
  8. public function flowdaorutestdata()
  9. {
  10. return array(
  11. 'typeid' => '办公耗材/笔',
  12. 'name' => '红色粉笔',
  13. 'num' => 'WP-829',
  14. 'guige' => '红色',
  15. 'xinghao' => '5厘米',
  16. 'price' => '0.1',
  17. 'unit' => '盒',
  18. 'stockcs' => '20',
  19. );
  20. }
  21. public function flowxiangfields(&$fields)
  22. {
  23. $fields['stock'] = '总库存';
  24. $where = '';
  25. if(ISMORECOM){
  26. $comid = arrvalue($this->rs,'comid','0');
  27. $where = ' and `comid`='.$comid.'';
  28. }
  29. $kcrow = m('godepot')->getall('1=1'.$where.'','*','`sort`');
  30. foreach($kcrow as $k1=>$rs1){
  31. $fields['stock_'.$rs1['id'].''] = $rs1['depotname'];
  32. }
  33. return $fields;
  34. }
  35. //
  36. public function flowrsreplace($rs, $lx=0)
  37. {
  38. //详情页下显示对应仓库库存
  39. if($lx==1){
  40. $drows = $this->db->getall("SELECT `depotid`,sum(count)count FROM `[Q]goodss` where aid=".$rs['id']." and `status`=1 GROUP BY `depotid`");
  41. foreach($drows as $k1=>$rs1)$rs['stock_'.$rs1['depotid'].''] = $rs1['count'];
  42. }
  43. return $rs;
  44. }
  45. //导入之前
  46. public function flowdaorubefore($rows)
  47. {
  48. $inarr = array();
  49. $db = m('goods');
  50. $num = 'goodstype';
  51. if(ISMORECOM && $cnum=$this->adminmodel->getcompanynum())$num.='_'.$cnum.'';
  52. foreach($rows as $k=>$rs){
  53. $rs['typeid'] = $this->option->gettypeid($num,$rs['typeid']);
  54. //判断是否存在
  55. $odi = $db->existsgoods($rs);
  56. if($odi)continue;
  57. $rs['price'] = floatval($this->rock->repempt($rs['price'],'0')); //金额
  58. //$rs['stockcs'] = (int)$this->rock->repempt(arrvalue($rs,'stockcs','0')); //无用
  59. $inarr[] = $rs;
  60. }
  61. return $inarr;
  62. }
  63. //导入后处理(刷新库存)
  64. public function flowdaoruafter($ddoa=array())
  65. {
  66. //初始库存
  67. m('goods')->setstock();
  68. }
  69. //删除时
  70. protected function flowdeletebill($sm)
  71. {
  72. m('goodss')->delete('`aid`='.$this->id.'');
  73. m('goods')->setstock();
  74. }
  75. }
粤ICP备19079148号