Commit 881ee7cb authored by libin's avatar libin

Merge remote-tracking branch 'origin/base-modify' into base-modify

parents 235aa57b 9ca2791e
......@@ -293,8 +293,8 @@ public class AppPermissionService {
}*/
//临时会员绑定
insertUserMemberByUserIdAndPhone(userid, username);
//参加新人活动
jionActivity(userid);
/*//参加新人活动
jionActivity(userid);*/
//创建钱包
walletBiz.createWalletByUserId(appUserLogin.getId());
// 登录结果要做做统一处理
......@@ -892,8 +892,8 @@ public class AppPermissionService {
relationBiz.bindByUserId(userid, small_id);
//发送短信通知用户
thirdFeign.sendCode(username, password, SystemConfig.TEMPLATECODE);
//参加新人活动
jionActivity(userid);
/* //参加新人活动
jionActivity(userid);*/
// 登录结果要做做统一处理
JSONObject data = autoLogin(userid, username, headimgurl, nickname,null);
// 到im注册,获取返回结果
......
......@@ -18,6 +18,8 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
......@@ -118,8 +120,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
List<UserCouponVo> list=mapper.getUserCouponsByType(userId,type,time,channel);
if(amout.compareTo(new BigDecimal("0.00"))>0&&list.size()>0){
for (UserCouponVo couponVo:list){
Integer status=2;
if(amout.compareTo(couponVo.getUsedAmount())>=0){
Integer status=2;
if(couponVo.getChannel()==1){
if (amout.compareTo(couponVo.getWithAmount())>=0){
status=1;
......@@ -127,11 +128,12 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
}else if (couponVo.getChannel()==3){
status=1;
}
}
couponVo.setStatus(status);
}
}
list.sort(Comparator.comparing(UserCouponVo::getStatus));
return ObjectRestResponse.succ(list);
}
......
......@@ -3,11 +3,7 @@ package com.xxfc.platform.activity.config;
import com.github.wxiaoqi.security.common.config.RabbitCommonConfig;
import com.github.wxiaoqi.security.common.config.rabbit.BindDTO;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import com.xxfc.platform.universal.constant.MQconstant;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
......@@ -23,12 +19,17 @@ public class RabbitActivityConfig extends RabbitCommonConfig {
public static final String INTEGRAL_QUEUE = "integral_queue";
public static final String POPULARZIE_0101_QUEUE = "popularzie.0101.queue";
//新人注册有礼
public static final String ACTIVITY_NEW_QUEUE = "activity.new.queue";
public static final String INTEGRAL_HANDLE_QUEUE = "integral_handle_queue";
static {
myQueue = new ArrayList<BindDTO>(){{
add(new BindDTO(INTEGRAL_QUEUE, RabbitConstant.ORDER_TOPIC, "order.#"));
add(new BindDTO(POPULARZIE_0101_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.register"));
add(new BindDTO(POPULARZIE_0101_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.auth"));
add(new BindDTO(ACTIVITY_NEW_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.register"));
add(new BindDTO(ACTIVITY_NEW_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.auth"));
add(new BindDTO(INTEGRAL_HANDLE_QUEUE, MQconstant.INTEGRAL_EXCHANGE, MQconstant.INTEGRAL_ROUTING_KEY));
}};
}
......
......@@ -4,6 +4,7 @@ package com.xxfc.platform.activity.handler;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.xxfc.platform.activity.biz.IntegralUserRecordBiz;
import com.xxfc.platform.activity.config.RabbitActivityConfig;
import com.xxfc.platform.activity.vo.IntegralUserRecordDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -26,7 +27,7 @@ public class IntegralMQHandler {
@Autowired
IntegralUserRecordBiz integralUserRecordBiz;
@RabbitListener(queues = "integral_handle_queue")
@RabbitListener(queues = {RabbitActivityConfig.INTEGRAL_HANDLE_QUEUE})
public void integralHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.dto.RegisterQueueDTO;
import com.rabbitmq.client.Channel;
import com.xxfc.platform.activity.biz.ActivityPopularizeBiz;
import com.xxfc.platform.activity.biz.ActivityUserJoinBiz;
import com.xxfc.platform.activity.biz.IntegralUserRecordBiz;
import com.xxfc.platform.activity.config.RabbitActivityConfig;
import com.xxfc.platform.activity.entity.ActivityPopularize;
......@@ -30,6 +31,9 @@ public class PopularizeMQHandler {
@Autowired
ActivityPopularizeBiz activityPopularizeBiz;
@Autowired
ActivityUserJoinBiz activityUserJoinBiz;
//@RabbitListener(queues = {RabbitActivityConfig.POPULARZIE_REGISTER_QUEUE,RabbitActivityConfig.POPULARZIE_AUTH_QUEUE})
@RabbitListener(queues = {RabbitActivityConfig.POPULARZIE_0101_QUEUE})
public void popularizeHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
......@@ -63,6 +67,41 @@ public class PopularizeMQHandler {
}
});
}
//新人注册有礼
@RabbitListener(queues = {RabbitActivityConfig.ACTIVITY_NEW_QUEUE})
public void activityNewHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
public void run() {
try {
String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8");
log.info("接收到的消息:msg = {}, 消息ID是:messageId = {} ", msg, messageId);
if (StringUtils.isNotBlank(msg)) {
RegisterQueueDTO registerQueueDTO = JSONObject.parseObject(msg, RegisterQueueDTO.class);
if(registerQueueDTO!=null&&(registerQueueDTO.getSign()==RegisterQueueDTO.SIGN_NEW||registerQueueDTO.getSign()==RegisterQueueDTO.SIGN_ACTIVATE)){
activityUserJoinBiz.joinActivity(registerQueueDTO.getAppUserId());
}
}
executorService.shutdown();
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
// 手动签收
channel.basicAck(deliveryTag, false);
} catch (Exception e) {
log.info("接收到的消息失败");
try {
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
} catch (IOException i) {
i.printStackTrace();
}
e.printStackTrace();
}
}
});
}
}
......@@ -48,7 +48,7 @@
and u.is_use=0 and u.expire_time &lt;#{time}
</if>
<if test="channel!=null and channel!=''">
and (c.channel=#{channel} or c.channel=1 )
and (c.channel=#{channel} or c.channel=0 )
</if>
<choose>
<when test="type==1">
......
......@@ -234,5 +234,5 @@ public class BaseOrder implements Serializable {
*/
@ApiModelProperty(value = "优惠券优惠的价格")
@Column(name = "coupon_amount")
private Integer couponAmount;
private BigDecimal couponAmount;
}
......@@ -94,6 +94,12 @@ public class AddRentVehicleDTO extends AddOrderCommonDTO{
@ApiModelProperty(value = "是否使用出租免费天数")
private Integer rentFreeDay;
/**
* 优惠券*
*/
@ApiModelProperty(value = "优惠卷卷号")
private String tickerNos;
public void setStartTime(Long startTime) {
this.startTime = startTime;
this.bookStartDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8)));
......
......@@ -70,8 +70,8 @@ public class AddTourDTO extends AddOrderCommonDTO{
Integer hasInsure;
/**
* 优惠券ids
* 优惠券*
*/
@ApiModelProperty(value = "优惠券ids")
private String couponIds;
@ApiModelProperty(value = "优惠卷卷号")
private String tickerNos;
}
......@@ -58,6 +58,7 @@ public class OrderRentVehicleController extends CommonBaseController {
setBookEndDate(vo.getBookEndDate());
}});
bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())? Arrays.asList(vo.getTickerNos().split(",")):null);
orderRentVehicleService.createOrder(bo);
return ObjectRestResponse.succ(bo.getOrder());
}
......
package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
......@@ -28,6 +29,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Arrays;
@Controller
@RequestMapping("orderTour")
@IgnoreClientToken
......@@ -55,6 +58,7 @@ public class OrderTourController extends BaseController<OrderTourDetailBiz,Order
@ApiOperation(value = "确认旅游订单")
public ObjectRestResponse<BaseOrder> add(@RequestBody AddTourDTO vo){
TourBO bo = BeanUtil.toBean(vo, TourBO.class);
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())? Arrays.asList(vo.getTickerNos().split(",")):null);
orderTourService.createOrder(bo);
return ObjectRestResponse.succ(bo.getOrder());
}
......@@ -70,6 +74,7 @@ public class OrderTourController extends BaseController<OrderTourDetailBiz,Order
bo.setChildNum(vo.getChildNumber());
TourGood tourGood = tourFeign.usableGet(bo.getGoodId()).getData();
bo.setTourGood(tourGood);
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())? Arrays.asList(vo.getTickerNos().split(",")):null);
return ObjectRestResponse.succ(orderTourService.calculatePrice(bo));
}
......@@ -96,5 +101,11 @@ public class OrderTourController extends BaseController<OrderTourDetailBiz,Order
@ApiModelProperty(value = "是否保险标记 1--要保险;0--不需要")
Integer hasInsure;
/**
* 优惠券*
*/
@ApiModelProperty(value = "优惠卷卷号")
private String tickerNos;
}
}
\ No newline at end of file
......@@ -142,9 +142,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
}
//如果有使用优惠券,则扣减
// if(BigDecimal.ZERO.compareTo(bo.getOrder().getCouponAmount()) >= 0) {
//
// }
if(BigDecimal.ZERO.compareTo(bo.getOrder().getCouponAmount()) < 0) {
activityFeign.use(bo.getAppUserDTO().getUserid(), bo.getTickerNo().get(0), bo.getOrder().getNo(), channel, bo.getOrder().getGoodsAmount(), ActivityFeign.TYPE_USE);
}
super.handleDetail(bo);
......
......@@ -138,6 +138,11 @@ public class OrderTourService extends AbstractOrderHandle<OrderTourDetailBiz, To
//扣減庫存
tourFeign.stock(bo.getSpePriceId(), bo.getTotalNumber(), TourFeign.STOCK_SUBTRACT);
//如果有使用优惠券,则扣减
if(BigDecimal.ZERO.compareTo(bo.getOrder().getCouponAmount()) < 0) {
activityFeign.use(bo.getAppUserDTO().getUserid(), bo.getTickerNo().get(0), bo.getOrder().getNo(), channel, bo.getOrder().getGoodsAmount(), ActivityFeign.TYPE_USE);
}
super.handleDetail(bo);
//发送定时取消订单(30分钟)
......
......@@ -22,10 +22,12 @@ public class MQServiceBiZ {
@Transactional(rollbackFor = Exception.class)
public ObjectRestResponse sendMessage(String exchange, String routKey, String json) {
log.info("发送消息到消息队列:exchange = {}, routingKey = {}, json = {}", exchange, routKey, json);
log.info("开始发送消息。。。");
Message message = MessageBuilder.withBody(json.getBytes())
.setContentType(MessageProperties.CONTENT_TYPE_JSON).setContentEncoding("utf-8")
.setMessageId(UUID.randomUUID() + "").build();
rabbitTemplate.convertAndSend(exchange, routKey, message);
log.info("发送成功。。。");
return ObjectRestResponse.succ();
}
}
......@@ -148,7 +148,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper,OrderPay> {
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId", newValue.getUserId());
jsonObject.put("amount", newValue.getAmount());
jsonObject.put("channelId", newValue.getOrderNo());
jsonObject.put("channelId", newValue.getId());
if(newValue.getChannel() == 1) {//租车
jsonObject.put("integralRuleCode", "RENTRV");
} else if(newValue.getChannel() == 2) { //旅游
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment