Commit fe7d731e authored by hezhen's avatar hezhen

添加优惠卷

parent f926c1bb
...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.common.util.ClientUtil; ...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.common.util.ClientUtil;
import com.github.wxiaoqi.security.common.util.EntityUtils; import com.github.wxiaoqi.security.common.util.EntityUtils;
import com.github.wxiaoqi.security.common.util.IpUtil; import com.github.wxiaoqi.security.common.util.IpUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -217,8 +218,8 @@ public class AuthController { ...@@ -217,8 +218,8 @@ public class AuthController {
} }
@PostMapping("/imi/login") @PostMapping("/imi/login")
public String loginImiWithToken(){ public JSONObject loginImiWithToken(){
return authService.loginImiWithToken(); return JsonResultUtil.createSuccessResultWithObj(authService.loginImiWithToken());
} }
} }
...@@ -709,7 +709,7 @@ public class AppPermissionService { ...@@ -709,7 +709,7 @@ public class AppPermissionService {
public String loginImiWithUserId(Integer userId){ public String loginImiWithUserId(Integer userId){
AppUserLogin appUserLogin = appUserLoginBiz.getUserById(userId); AppUserLogin appUserLogin = appUserLoginBiz.getUserById(userId);
String token = loginIm(appUserLogin.getUsername(), appUserLogin.getImPassword(), userId); String token = loginIm(appUserLogin.getUsername(), appUserLogin.getImPassword(), appUserLogin.getImUserid());
return token; return token;
} }
......
...@@ -109,15 +109,33 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -109,15 +109,33 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
} }
//获取我的优惠卷 //获取我的优惠卷
public ObjectRestResponse getCouponList(Integer userId,int type){ public ObjectRestResponse getCouponList(Integer userId,int type,Integer channel,BigDecimal amout){
if (userId==null||userId==0){ if (userId==null||userId==0){
log.error("----参数不能为空"); log.error("----参数不能为空");
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
} }
Long time=System.currentTimeMillis(); Long time=System.currentTimeMillis();
return ObjectRestResponse.succ(mapper.getUserCouponsByType(userId,type,time)); 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){
if(couponVo.getChannel()==1){
if (amout.compareTo(couponVo.getWithAmount())>=0){
status=1;
}
}else if (couponVo.getChannel()==3){
status=1;
}
}
couponVo.setStatus(status);
}
}
return ObjectRestResponse.succ(list);
} }
//获取单个优惠卷 //获取单个优惠卷
public UserCouponVo getUserCoupon(String tickerNo){ public UserCouponVo getUserCoupon(String tickerNo){
if (StringUtils.isBlank(tickerNo)){ if (StringUtils.isBlank(tickerNo)){
......
...@@ -17,7 +17,7 @@ import java.util.List; ...@@ -17,7 +17,7 @@ import java.util.List;
public interface UserCouponMapper extends Mapper<UserCoupon> { public interface UserCouponMapper extends Mapper<UserCoupon> {
//我的优惠卷 //我的优惠卷
public List<UserCouponVo> getUserCouponsByType(@Param("userId")Integer userId,@Param("type")int type,@Param("time")Long time); public List<UserCouponVo> getUserCouponsByType(@Param("userId")Integer userId,@Param("type")int type,@Param("time")Long time,@Param("channel")Integer channel);
//单个优惠卷 //单个优惠卷
public UserCouponVo getUserCoupon(@Param("tickerNo")String tickerNo); public UserCouponVo getUserCoupon(@Param("tickerNo")String tickerNo);
......
...@@ -27,15 +27,23 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz> ...@@ -27,15 +27,23 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz>
return baseBiz.authledCoupon(userId); return baseBiz.authledCoupon(userId);
} }
/**
*
* @param type 0-未使用;1-已使用;3-已过期
* @param channel 1-租车;2-旅游;null-全部
* @return
*/
@ApiOperation("我的优惠卷") @ApiOperation("我的优惠卷")
@RequestMapping(value = "/list/{type}", method = RequestMethod.GET) @RequestMapping(value = "/coupon/list", method = RequestMethod.GET)
public ObjectRestResponse list(@PathVariable Integer type) { public ObjectRestResponse list(@RequestParam(value = "type",defaultValue = "0") Integer type,
@RequestParam(value = "channel") Integer channel,
@RequestParam(value = "amount",defaultValue = "0.00") BigDecimal amount) {
AppUserDTO userInfo = getUserInfo(); AppUserDTO userInfo = getUserInfo();
Integer userId = userInfo.getUserid(); Integer userId = userInfo.getUserid();
if(userId==null){ if(userId==null){
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
} }
return baseBiz.getCouponList(userId,type); return baseBiz.getCouponList(userId,type,channel,amount);
} }
@ApiOperation("单个优惠卷信息") @ApiOperation("单个优惠卷信息")
...@@ -80,4 +88,6 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz> ...@@ -80,4 +88,6 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz>
} }
\ No newline at end of file
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
<if test="type==2"> <if test="type==2">
and u.is_use=0 and u.expire_time &lt;#{time} and u.is_use=0 and u.expire_time &lt;#{time}
</if> </if>
<if test="channel!=null and channel!=''">
and (c.channel=#{channel} or c.channel=1 )
</if>
<choose> <choose>
<when test="type==1"> <when test="type==1">
ORDER BY u.use_time DESC ORDER BY u.use_time DESC
......
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