Pmgdiscount.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Pmgdiscount extends BaseModel
  12. {
  13. public function getPmgdiscountInfoByGoodsInfo($goods_info)
  14. {
  15. //判断店铺是否开启会员折扣
  16. $store = Db::name('store')->where('store_id', $goods_info['store_id'])->find();
  17. if ($store['store_mgdiscount_state'] != 1) {
  18. return;
  19. }
  20. //判断套餐时间
  21. $mgdiscountquota_model = model('pmgdiscountquota');
  22. if ($store['is_platform_store'] != 1 && intval(config('ds_config.mgdiscount_price')) != 0) { //非自营店且促销套餐价格非零就需要检查是否购买了套餐
  23. $current_mgdiscount_quota = $mgdiscountquota_model->getMgdiscountquotaCurrent($goods_info['store_id']);
  24. if (empty($current_mgdiscount_quota) || $current_mgdiscount_quota['mgdiscountquota_endtime'] < TIMESTAMP) {
  25. return;
  26. }
  27. }
  28. //查看此商品是否单独设置了折扣
  29. if ($goods_info['goods_mgdiscount'] != '') {
  30. return unserialize($goods_info['goods_mgdiscount']);
  31. }
  32. //当店铺设置了店铺会员等级折扣
  33. if ($store['store_mgdiscount'] != '') {
  34. return unserialize($store['store_mgdiscount']);
  35. }
  36. return;
  37. }
  38. }