queue.model.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /**
  3. * 队列模型
  4. *
  5. * 方法名需要和 QueueClient::push中第一个参数一致,如:
  6. * QueueClient::push('addPoint',$queue_content);
  7. * public function addPoint($queue_content){...}
  8. *
  9. */
  10. defined('InShopNC') or exit('Access Invalid!');
  11. class queueModel extends Model{
  12. /**
  13. * 添加会员积分
  14. * @param unknown $member_info
  15. */
  16. public function addPoint($member_info) {
  17. $points_model = Model('points');
  18. $points_model->savePointsLog('login',array('pl_memberid'=>$member_info['member_id'],'pl_membername'=>$member_info['member_name']),true);
  19. return true;
  20. }
  21. /**
  22. * 更新抢购信息
  23. * @param unknown $groupbuy_info
  24. * @throws Exception
  25. */
  26. public function editGroupbuySaleCount($groupbuy_info) {
  27. $model_groupbuy = Model('groupbuy');
  28. $data = array();
  29. $data['buyer_count'] = array('exp','buyer_count+1');
  30. $data['buy_quantity'] = array('exp','buy_quantity+'.$groupbuy_info['quantity']);
  31. $model_groupbuy->editGroupbuy($data,array('groupbuy_id'=>$groupbuy_info['groupbuy_id']));
  32. return true;
  33. }
  34. /**
  35. * 更新使用的代金券状态
  36. * @param $input_voucher_list
  37. * @throws Exception
  38. */
  39. public function editVoucherState($voucher_list) {
  40. $model_voucher = Model('voucher');
  41. foreach ($voucher_list as $store_id => $voucher_info) {
  42. $update = $model_voucher->editVoucher(array('voucher_state'=>2),array('voucher_id'=>$voucher_info['voucher_id']));
  43. // if (!$update) throw new Exception('代金券更新失败');
  44. // 发送用户店铺消息
  45. $send = new message_sender();
  46. $send->set('member_id', $voucher_info['voucher_owner_id']);
  47. $send->set('code', 'voucher_use');
  48. $param = array();
  49. $param['voucher_code'] = $voucher_info['voucher_code'];
  50. $param['voucher_url'] = urlShop('member_voucher', 'index');
  51. $send->send($param);
  52. unset($send);
  53. }
  54. }
  55. /**
  56. * 订单订单扩展表中收货人所在省份
  57. * @param unknown $order
  58. * @return void|boolean
  59. */
  60. public function editReciverProid($order) {
  61. if (!is_array($order['order_ids']) || empty($order['area_id'])) return ;
  62. $model_area = Model('area');
  63. $area_info = $model_area->getAreaInfo(array('area_id'=>$order['area_id']),'area_parent_id');
  64. $model_order = Model('order');
  65. $model_order->editOrderCommon(array('reciver_province_id'=>$area_info['area_parent_id']),array('order_id'=>array('in',$order['order_ids'])));
  66. return true;
  67. }
  68. /**
  69. * 删除购物车
  70. * @param unknown $cart
  71. */
  72. // public function delCart($cart) {
  73. // $model_cart = Model('cart');
  74. // if (!is_array($cart['cart_ids']) || empty($cart['buyer_id'])) return ;
  75. // $model_cart->delCart('db',array('buyer_id'=>$cart['buyer_id'],'cart_id'=>array('in',$cart['cart_ids'])));
  76. // }
  77. /**
  78. * 根据抢购id更新商品促销价格
  79. * @param array $groupbuy
  80. */
  81. public function updateGoodsPromotionPriceByGroupbuyId($groupbuy_id) {
  82. $groupbuy_info = Model('groupbuy')->getGroupbuyInfo(array('groupbuy_id' => $groupbuy_id, 'start_time' => array('lt', time()), 'end_time' => array('gt', time())));
  83. if(!empty($groupbuy_info)) {
  84. // 没有促销使用原价
  85. Model('goods')->editGoods(array('goods_promotion_price' => $groupbuy_info['groupbuy_price'], 'goods_promotion_type' => 1), array('goods_commonid' => $groupbuy_info['goods_commonid']));
  86. }
  87. return true;
  88. }
  89. /**
  90. * 根据限时折扣id更新促销价格
  91. */
  92. public function updateGoodsPromotionPriceByXianshiId($xianshi_id) {
  93. $xianshigoods_array = Model('p_xianshi_goods')->getXianshiGoodsList(array('xianshi_id' => $xianshi_id, 'start_time' => array('lt', time()), 'end_time' => array('gt', time())));
  94. if(!empty($xianshigoods_array)) {
  95. foreach ($xianshigoods_array as $val) {
  96. $goods_info = Model('goods')->getGoodsInfo(array('goods_id' => $val['goods_id']), 'goods_promotion_type');
  97. // 如果存在抢购促销 结束循环
  98. if ($goods_info['goods_promotion_type'] == 1) {
  99. continue;
  100. }
  101. // 更新促销价格
  102. $this->editGoods(array('goods_promotion_price' => $val['xianshi_price'], 'goods_promotion_type' => 2), array('goods_id' => $val['goods_id']));
  103. }
  104. }
  105. return true;
  106. }
  107. /**
  108. * 根据商品id更新促销价格
  109. */
  110. public function updateGoodsPromotionPriceByGoodsId($goods_id) {
  111. Model('goods')->editGoodsPromotionPrice(array('goods_id' => $goods_id));
  112. return true;
  113. }
  114. /**
  115. * 根据商品公共id更新促销价格
  116. */
  117. public function updateGoodsPromotionPriceByGoodsCommonId($goods_commonid) {
  118. Model('goods')->editGoodsPromotionPrice(array('goods_commonid' => $goods_commonid));
  119. return true;
  120. }
  121. /**
  122. * 发送店铺消息
  123. */
  124. public function sendStoreMsg($param) {
  125. $send = new sendStoreMsg();
  126. $send->set('code', $param['code']);
  127. $send->set('store_id', $param['store_id']);
  128. $send->send($param['param']);
  129. return true;
  130. }
  131. /**
  132. * 发送会员消息
  133. */
  134. public function sendMemberMsg($param) {
  135. $send = new message_sender();
  136. $send->set('code', $param['code']);
  137. $send->set('member_id', $param['member_id']);
  138. $send->send($param['param']);
  139. return true;
  140. }
  141. }