queue.model.php 5.8 KB

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