Pmansongrule.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * 满即送活动规则模型
  4. *
  5. */
  6. namespace app\common\model;
  7. use think\facade\Db;
  8. /**
  9. * ============================================================================
  10. *
  11. * ============================================================================
  12. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  13. * 网站地址: https://www.valimart.net/
  14. * ----------------------------------------------------------------------------
  15. *
  16. * ============================================================================
  17. * 数据层模型
  18. */
  19. class Pmansongrule extends BaseModel {
  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. $mansong_rule_list = Db::name('pmansongrule')->where('mansong_id',$mansong_id)->order('mansongrule_price desc')->select()->toArray();
  29. if (!empty($mansong_rule_list)) {
  30. $goods_model = model('goods');
  31. for ($i = 0, $j = count($mansong_rule_list); $i < $j; $i++) {
  32. $goods_id = intval($mansong_rule_list[$i]['goods_id']);
  33. if (!empty($goods_id)) {
  34. $goods_info = $goods_model->getGoodsOnlineInfoByID($goods_id);
  35. if (!empty($goods_info)) {
  36. if (empty($mansong_rule_list[$i]['mansong_goods_name'])) {
  37. $mansong_rule_list[$i]['mansong_goods_name'] = $goods_info['goods_name'];
  38. }
  39. $mansong_rule_list[$i]['goods_image'] = $goods_info['goods_image'];
  40. $mansong_rule_list[$i]['goods_image_url'] = goods_cthumb($goods_info['goods_image'], $goods_info['store_id']);
  41. $mansong_rule_list[$i]['goods_storage'] = $goods_info['goods_storage'];
  42. $mansong_rule_list[$i]['goods_id'] = $goods_id;
  43. $mansong_rule_list[$i]['goods_url'] = (string)url('Goods/index', array('goods_id' => $goods_id));
  44. }else{
  45. $mansong_rule_list[$i]['goods_id'] = 0;
  46. }
  47. }
  48. }
  49. }
  50. return $mansong_rule_list;
  51. }
  52. /**
  53. * 增加
  54. * @access public
  55. * @author csdeshang
  56. * @param array $data 数据
  57. * @return bool
  58. */
  59. public function addMansongrule($data) {
  60. return Db::name('pmansongrule')->insertGetId($data);
  61. }
  62. /**
  63. * 批量增加
  64. * @access public
  65. * @author csdeshang
  66. * @param array $array 参数内容
  67. * @return bool
  68. */
  69. public function addMansongruleArray($array) {
  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. return Db::name('pmansongrule')->where($condition)->delete();
  81. }
  82. }