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