Merge branch 'dev' of http://139.159.177.244:3000/hurui/hai-server into dev
commit
f30f0f92bf
File diff suppressed because one or more lines are too long
@ -0,0 +1,114 @@ |
||||
package com.cweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.SessionObject; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.*; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.*; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.dao.DeadlockLoserDataAccessException; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.math.BigDecimal; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @Auther: 胡锐 |
||||
* @Description: |
||||
* @Date: 2021/4/20 23:47 |
||||
*/ |
||||
@Controller |
||||
@RequestMapping(value = "/couponAgent") |
||||
@Api(value = "代理商接口") |
||||
public class HighCouponAgentController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighCouponAgentController.class); |
||||
|
||||
@Resource |
||||
private HighCouponAgentService highCouponAgentService; |
||||
|
||||
@Resource |
||||
private HighCouponService highCouponService; |
||||
|
||||
@Resource |
||||
private HighCouponCodeService highCouponCodeService; |
||||
|
||||
@RequestMapping(value = "/useConvertCode", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "兑换码使用") |
||||
public ResponseData useConvertCode(@RequestBody JSONObject body) { |
||||
try { |
||||
|
||||
if (body == null || StringUtils.isBlank(body.getString("code"))) { |
||||
log.error("HighCouponAgentController -> queryConvertCode() error!",""); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询兑换码
|
||||
HighCouponAgentCode convertCode = highCouponAgentService.getConvertCode(body.getString("code")); |
||||
if (convertCode == null) { |
||||
log.error("HighCouponAgentController -> queryConvertCode() error!","无效的兑换码"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码"); |
||||
} |
||||
if (convertCode.getStatus() == 3) { |
||||
log.error("HighCouponAgentController -> queryConvertCode() error!","兑换码已被使用"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); |
||||
} |
||||
if (convertCode.getCouponCodeId() != null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); |
||||
} |
||||
return ResponseMsgUtil.success(highCouponAgentService.useConvertCode(body.getString("code"))); |
||||
|
||||
} catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) { |
||||
log.error("HighActivityController -> userLottery() error!", "服务器繁忙"); |
||||
return ResponseMsgUtil.builderResponse(ErrorCode.SERVER_BUSY_ERROR.getCode(),ErrorCode.SERVER_BUSY_ERROR.getMsg(),null); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighCouponAgentController --> useConvertCode() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/convertCodeDetail", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "兑换码详情") |
||||
public ResponseData convertCodeDetail(@RequestParam(name = "code", required = true) String code) { |
||||
try { |
||||
|
||||
// 查询兑换码
|
||||
HighCouponAgentCode couponAgentCode = highCouponAgentService.getConvertCode(code); |
||||
if (couponAgentCode == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到销售码"); |
||||
} |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("couponInfo", highCouponService.getCouponById(couponAgentCode.getCouponId())); |
||||
map.put("couponCode", highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId())); |
||||
map.put("couponAgentCode", couponAgentCode); |
||||
return ResponseMsgUtil.success(map); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighCouponAgentController --> getConvertCodeDetail() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,33 @@ |
||||
package com.hai.service; |
||||
|
||||
/** |
||||
* @serviceName HltMerchantService.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 测试接口
|
||||
* @createTime 11:46 上午 2021/12/15 |
||||
**/ |
||||
public interface HighTestService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @name getReadFile.java |
||||
* @Description //读取文件
|
||||
* @Date 5:31 下午 2021/12/16 |
||||
* @Param [] |
||||
* @return void |
||||
*/ |
||||
void getReadFile() throws Exception; |
||||
|
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @name getUserDiscount.java |
||||
* @Description // 赠送用户卡券
|
||||
* @Date 7:14 下午 2021/12/24 |
||||
* @Param [] |
||||
* @return void |
||||
*/ |
||||
void getUserDiscount(Long id) throws Exception; |
||||
|
||||
} |
@ -0,0 +1,136 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
|
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.utils.RedisUtil; |
||||
import com.hai.dao.HighUserEtcMapper; |
||||
import com.hai.entity.HighDiscountAgentCode; |
||||
import com.hai.entity.HighUser; |
||||
import com.hai.entity.HighUserEtc; |
||||
import com.hai.service.*; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.io.BufferedReader; |
||||
import java.io.File; |
||||
import java.io.FileReader; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
|
||||
@Service("highTestService") |
||||
public class HighTestServiceImpl implements HighTestService { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighTestService.class); |
||||
|
||||
@Resource |
||||
private HighUserService highUserService; |
||||
|
||||
@Resource |
||||
private HighUserEtcMapper highUserEtcMapper; |
||||
|
||||
@Resource |
||||
private HighDiscountAgentCodeService highDiscountAgentCodeService; |
||||
|
||||
|
||||
@Resource |
||||
private HighDiscountUserRelService highDiscountUserRelService; |
||||
|
||||
@Autowired |
||||
private RedisUtil redisUtil; |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) |
||||
public void getReadFile() throws Exception { |
||||
// BufferedReader bufferedReader = null;
|
||||
//
|
||||
// Map<String , String> mapUser = new HashMap<>();
|
||||
//
|
||||
// //cookie过期时间为7天
|
||||
// int EXPIRE = 3600*24*7;
|
||||
//
|
||||
// List<HighUser> highUsers = highUserService.getListUser(mapUser);
|
||||
//
|
||||
// for (HighUser user: highUsers) {
|
||||
// redisUtil.set(user.getPhone(), user.getPhone(), EXPIRE);
|
||||
// }
|
||||
//
|
||||
// FileReader fileReader = new FileReader("/home/project/hsg/readFile/etccq.txt");
|
||||
// if (fileReader == null) {
|
||||
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "读取空数据");
|
||||
// }
|
||||
//
|
||||
// bufferedReader = new BufferedReader(fileReader);
|
||||
// String temp = bufferedReader.readLine();
|
||||
// int i = 0;
|
||||
// while (temp != null) {
|
||||
// i++;
|
||||
// String[] arr = temp.split(";");
|
||||
//
|
||||
// String phone = (String) redisUtil.get(arr[3]);
|
||||
//
|
||||
// if (phone == null || highUsers.size() == 0) {
|
||||
// HighUser user = new HighUser();
|
||||
//
|
||||
// user.setStatus(1);
|
||||
// user.setInfoCompleteStatus(1);
|
||||
// user.setGold(0);
|
||||
// user.setRegTime(new Date());
|
||||
// user.setName(arr[2]);
|
||||
// user.setPhone(arr[3]);
|
||||
// user.setExt4("1");
|
||||
//
|
||||
// highUserService.insertUser(user);
|
||||
//
|
||||
// HighUserEtc userEtc = new HighUserEtc();
|
||||
//
|
||||
// userEtc.setCreateTime(new Date());
|
||||
// userEtc.setStatus(1);
|
||||
// userEtc.setUserId(user.getId());
|
||||
// userEtc.setCustomerName(arr[2]);
|
||||
// userEtc.setCustomerTel(arr[3]);
|
||||
// userEtc.setVehicleId(arr[0]);
|
||||
// userEtc.setVehiclePlate(arr[1]);
|
||||
//
|
||||
// highUserEtcMapper.insert(userEtc);
|
||||
//
|
||||
//// Map<String , Object> map = new HashMap<>();
|
||||
//// map.put("userId" , user.getId());
|
||||
//// map.put("userPhone" , user.getPhone());
|
||||
//// map.put("discountPackageId" , 48);
|
||||
//
|
||||
//// highDiscountPackageService.freeUserDiscountPackage(map);
|
||||
// }
|
||||
//
|
||||
// temp = bufferedReader.readLine();
|
||||
// }
|
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) |
||||
public void getUserDiscount(Long id) throws Exception{ |
||||
List<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByStatus(id , 1); |
||||
Map<String , String> map = new HashMap<>(); |
||||
map.put("ext4" , "1"); |
||||
List<HighUser> userList = highUserService.getListUser(map); |
||||
|
||||
int num = 0; |
||||
for (HighUser user : userList) { |
||||
// 领取优惠券
|
||||
highDiscountUserRelService.receiveDiscount(user.getId(), codeList.get(num).getId()); |
||||
num++; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue