p_mansong_rule.model.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * 满即送活动规则模型
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class p_mansong_ruleModel extends Model{
  11. public function __construct(){
  12. parent::__construct('p_mansong_rule');
  13. }
  14. /**
  15. * 读取满即送规则列表
  16. * @param array $mansong_id 查询条件
  17. * @param int $page 分页数
  18. * @param string $order 排序
  19. * @param string $field 所需字段
  20. * @return array 满即送套餐列表
  21. *
  22. */
  23. public function getMansongRuleListByID($mansong_id) {
  24. $condition = array();
  25. $condition['mansong_id'] = $mansong_id;
  26. $mansong_rule_list = $this->where($condition)->order('price desc')->select();
  27. if(!empty($mansong_rule_list)) {
  28. $model_goods = 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 = $model_goods->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'] = 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'] = urlShop('goods', 'index', array('goods_id' => $goods_id));
  42. }
  43. }
  44. }
  45. }
  46. return $mansong_rule_list;
  47. }
  48. /*
  49. * 增加
  50. * @param array $param
  51. * @return bool
  52. *
  53. */
  54. public function addMansongRule($param){
  55. return $this->insert($param);
  56. }
  57. /*
  58. * 批量增加
  59. * @param array $array
  60. * @return bool
  61. *
  62. */
  63. public function addMansongRuleArray($array){
  64. return $this->insertAll($array);
  65. }
  66. /*
  67. * 删除
  68. * @param array $condition
  69. * @return bool
  70. *
  71. */
  72. public function delMansongRule($condition){
  73. return $this->where($condition)->delete();
  74. }
  75. }