Pmansongrule.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * 满即送活动规则模型
  4. *
  5. */
  6. namespace app\common\model;
  7. use think\facade\Db;
  8. /**
  9. *
  10. *
  11. * ----------------------------------------------------------------------------
  12. *
  13. * 数据层模型
  14. */
  15. class Pmansongrule extends BaseModel
  16. {
  17. /**
  18. * 读取满即送规则列表
  19. * @access public
  20. * @author csdeshang
  21. * @param type $mansong_id 满即送ID
  22. * @return type
  23. */
  24. public function getMansongruleListByID($mansong_id)
  25. {
  26. $mansong_rule_list = Db::name('pmansongrule')->where('mansong_id', $mansong_id)->order('mansongrule_price desc')->select()->toArray();
  27. if (!empty($mansong_rule_list)) {
  28. $goods_model = model('goods');
  29. for ($i = 0, $j = count($mansong_rule_list); $i < $j; $i++) {
  30. $goods_id = intval($mansong_rule_list[$i]['goods_id']);
  31. if (!empty($goods_id)) {
  32. $goods_info = $goods_model->getGoodsOnlineInfoByID($goods_id);
  33. if (!empty($goods_info)) {
  34. if (empty($mansong_rule_list[$i]['mansong_goods_name'])) {
  35. $mansong_rule_list[$i]['mansong_goods_name'] = $goods_info['goods_name'];
  36. }
  37. $mansong_rule_list[$i]['goods_image'] = $goods_info['goods_image'];
  38. $mansong_rule_list[$i]['goods_image_url'] = goods_cthumb($goods_info['goods_image'], $goods_info['store_id']);
  39. $mansong_rule_list[$i]['goods_storage'] = $goods_info['goods_storage'];
  40. $mansong_rule_list[$i]['goods_id'] = $goods_id;
  41. $mansong_rule_list[$i]['goods_url'] = (string)url('Goods/index', array('goods_id' => $goods_id));
  42. } else {
  43. $mansong_rule_list[$i]['goods_id'] = 0;
  44. }
  45. }
  46. }
  47. }
  48. return $mansong_rule_list;
  49. }
  50. /**
  51. * 增加
  52. * @access public
  53. * @author csdeshang
  54. * @param array $data 数据
  55. * @return bool
  56. */
  57. public function addMansongrule($data)
  58. {
  59. return Db::name('pmansongrule')->insertGetId($data);
  60. }
  61. /**
  62. * 批量增加
  63. * @access public
  64. * @author csdeshang
  65. * @param array $array 参数内容
  66. * @return bool
  67. */
  68. public function addMansongruleArray($array)
  69. {
  70. return Db::name('pmansongrule')->insertAll($array);
  71. }
  72. /**
  73. * 删除
  74. * @access public
  75. * @author csdeshang
  76. * @param array $condition 条件
  77. * @return bool
  78. */
  79. public function delMansongrule($condition)
  80. {
  81. return Db::name('pmansongrule')->where($condition)->delete();
  82. }
  83. }