IntegralModel.class.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace Home\Model;
  3. use Think\Model;
  4. /**
  5. * 拼团模型模型
  6. * @author fish
  7. *
  8. */
  9. class IntegralModel {
  10. /**
  11. 检测会员积分是否足够支付订单
  12. **/
  13. public function check_user_score_can_pay($member_id, $sku_str ='', $goods_id)
  14. {
  15. $member_info = M('lionfish_comshop_member')->field('score')->where( array('member_id' => $member_id ) )->find();
  16. if( !empty($sku_str) )
  17. {
  18. $mult_value_info = $goods_option_mult_value = M('lionfish_comshop_goods_option_item_value')->where( array('goods_id' =>$goods_id,'option_item_ids' => $sku_str ) )->find();
  19. //marketprice
  20. if($mult_value_info['marketprice'] > $member_info['score'])
  21. {
  22. return array('code' => 1,'cur_score' => $member_info['score'],'pay_score' => $mult_value_info['marketprice']);
  23. }else{
  24. return array('code' => 0);
  25. }
  26. }else{
  27. //price
  28. $intgral_goods_info = M('lionfish_comshop_goods')->field('price')->where( array('id' => $goods_id ) )->find();
  29. if($intgral_goods_info['price'] > $member_info['score'])
  30. {
  31. return array('code' => 1,'cur_score' => $member_info['score'],'pay_score' => $intgral_goods_info['price']);
  32. }else{
  33. return array('code' => 0);
  34. }
  35. }
  36. }
  37. /**
  38. 检测会员积分是否足够支付订单
  39. **/
  40. public function check_user_score_quantity_can_pay($member_id, $sku_str ='', $goods_id, $quantity)
  41. {
  42. $member_info = M('lionfish_comshop_member')->field('score')->where( array('member_id' => $member_id ) )->find();
  43. if( !empty($sku_str) )
  44. {
  45. $mult_value_info = $goods_option_mult_value = M('lionfish_comshop_goods_option_item_value')->where( array('goods_id' =>$goods_id,'option_item_ids' => $sku_str ) )->find();
  46. //marketprice
  47. if($mult_value_info['marketprice']*$quantity > $member_info['score'])
  48. {
  49. return array('code' => 1,'cur_score' => $member_info['score'],'pay_score' => $mult_value_info['marketprice']*$quantity);
  50. }else{
  51. return array('code' => 0);
  52. }
  53. }else{
  54. //price
  55. $intgral_goods_info = M('lionfish_comshop_goods')->field('price')->where( array('id' => $goods_id ) )->find();
  56. if($intgral_goods_info['price']*$quantity > $member_info['score'])
  57. {
  58. return array('code' => 1,'cur_score' => $member_info['score'],'pay_score' => $intgral_goods_info['price']*$quantity);
  59. }else{
  60. return array('code' => 0);
  61. }
  62. }
  63. }
  64. }