queue.model.php 5.8 KB

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