-- 新版提交
This commit is contained in:
@@ -11,25 +11,23 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.MD5Utils;
|
||||
import com.peanut.modules.book.entity.CouponHistoryEntity;
|
||||
import com.peanut.modules.book.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.book.entity.TransactionDetailsEntity;
|
||||
import com.peanut.modules.book.service.CouponHistoryService;
|
||||
import com.peanut.modules.book.service.PayPaymentOrderService;
|
||||
import com.peanut.modules.book.service.TransactionDetailsService;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.sys.service.SysUserTokenService;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
@@ -48,12 +46,18 @@ public class MyUserController {
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private SysUserTokenService sysUserTokenService;
|
||||
@Autowired
|
||||
private CouponHistoryService couponHistoryService;
|
||||
@Autowired
|
||||
private BookBuyConfigService bookBuyConfigService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
|
||||
/**
|
||||
@@ -107,8 +111,10 @@ public class MyUserController {
|
||||
String password = user.getPassword();
|
||||
String saltMD5 = MD5Utils.getSaltMD5(password);
|
||||
user.setPassword(saltMD5);
|
||||
userService.updateById(user);
|
||||
}else{
|
||||
userService.update(user);
|
||||
}
|
||||
userService.updateById(user);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
@@ -321,7 +327,9 @@ public class MyUserController {
|
||||
String cellPhone = jsonObject.getJSONObject("obj").getString("cellPhone");
|
||||
String customerIcons = jsonObject.getJSONObject("obj").getString("customerIcons");
|
||||
String nameCN = jsonObject.getJSONObject("obj").getString("nameCN");
|
||||
System.out.println(yljkOid);
|
||||
// String password = jsonObject.getJSONObject("obj").getString("pass");
|
||||
|
||||
System.out.println("=====================yljkOid=============================="+yljkOid);
|
||||
|
||||
|
||||
//查询 当前 花生账号 和 当前绑定的 一路健康账号是否有绑定 关系
|
||||
@@ -398,7 +406,7 @@ public class MyUserController {
|
||||
myUserEntity.setAvatar(customerIcons);
|
||||
userService.save(myUserEntity);
|
||||
R r = sysUserTokenService.createToken(myUserEntity.getId());
|
||||
return R.ok().put("userInfo",myUserEntity).put("token",r);
|
||||
return R.ok().put("userInfo",myUserEntity).put("token",r);
|
||||
}
|
||||
//判断当前手机号用户是否绑定过一路健康账号
|
||||
if (userEntity.getYljkOid() != null){
|
||||
@@ -411,7 +419,9 @@ public class MyUserController {
|
||||
userEntity.setAvatar(customerIcons);
|
||||
userService.updateById(userEntity);
|
||||
R r = sysUserTokenService.createToken(userEntity.getId());
|
||||
// todo 为什么验证成功以后不能实现页面跳转登录 R返回更新生成的token和电话
|
||||
return R.ok().put("userInfo",userEntity).put("token",r);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/test")
|
||||
@@ -426,10 +436,19 @@ public class MyUserController {
|
||||
*/
|
||||
@RequestMapping("/buyEbook")
|
||||
public R buyEbook(@RequestParam Map<String, Object> params){
|
||||
String msg = "";
|
||||
String bookId = (String) params.get("bookId");
|
||||
String userId = (String) params.get("userId");
|
||||
String couponId = (String) params.get("couponId");
|
||||
String msg = userService.buyEbook(userId, bookId,couponId);
|
||||
BookEntity book = this.bookService.getById(bookId);
|
||||
MyUserEntity user = this.userService.getById(userId);
|
||||
if(1 == book.getIsVip()){
|
||||
if(!"1".equals(user.getVip())){
|
||||
msg ="当前书籍为VIP书籍,请开通VIP后购买!";
|
||||
return R.ok().put("msg", msg).put("status","error");
|
||||
}
|
||||
}
|
||||
msg = userService.buyEbook(userId, bookId,couponId);
|
||||
|
||||
if (msg.equals("当前书籍以购买,请勿重复购买!")) {
|
||||
return R.ok().put("msg",msg).put("status","error");
|
||||
@@ -452,12 +471,12 @@ public class MyUserController {
|
||||
MyUserEntity byId = userService.getById(id);
|
||||
int i = 0;
|
||||
if (pointType.equals("0")) {
|
||||
i = byId.getPeanutCoin() + Integer.valueOf(pointAmount);
|
||||
byId.setPeanutCoin(i);
|
||||
i = byId.getPeanutCoin().intValue() + Integer.valueOf(pointAmount);
|
||||
byId.setPeanutCoin(new BigDecimal(i));
|
||||
}else {
|
||||
i = byId.getPeanutCoin() - Integer.valueOf(pointAmount);
|
||||
i = byId.getPeanutCoin().intValue() - Integer.valueOf(pointAmount);
|
||||
if (i >= 0) {
|
||||
byId.setPeanutCoin(i);
|
||||
byId.setPeanutCoin(new BigDecimal(i));
|
||||
}else {
|
||||
return R.error("余额不足!扣除失败!");
|
||||
}
|
||||
@@ -466,11 +485,15 @@ public class MyUserController {
|
||||
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setUserId(Integer.valueOf(id));
|
||||
transactionDetailsEntity.setChangeAmount(new BigDecimal(Integer.valueOf(pointAmount)));
|
||||
transactionDetailsEntity.setOrderType("后台充值操作");
|
||||
transactionDetailsEntity.setOrderType("后台充扣操作");
|
||||
transactionDetailsEntity.setTel(byId.getTel());
|
||||
transactionDetailsEntity.setUserName(byId.getNickname());
|
||||
transactionDetailsEntity.setNote(params.get("note"));
|
||||
if (pointType.equals("0")) {
|
||||
transactionDetailsEntity.setChangeAmount(new BigDecimal(Integer.valueOf(pointAmount)));
|
||||
transactionDetailsEntity.setRemark("充值");
|
||||
}else {
|
||||
transactionDetailsEntity.setChangeAmount(new BigDecimal(Integer.valueOf(pointAmount)).negate());
|
||||
transactionDetailsEntity.setRemark("扣费");
|
||||
}
|
||||
BigDecimal balance = new BigDecimal(i);
|
||||
@@ -479,7 +502,7 @@ public class MyUserController {
|
||||
|
||||
|
||||
// 插入 花生币 充值记录
|
||||
// PayPaymentOrderEntity payPaymentOrderEntity = new PayPaymentOrderEntity();
|
||||
// IosPayOrderEntity payPaymentOrderEntity = new IosPayOrderEntity();
|
||||
// payPaymentOrderEntity.setUserId(Integer.valueOf(id));
|
||||
// payPaymentOrderEntity.setRealAmount(new BigDecimal(byId.getPeanutCoin()));
|
||||
// payPaymentOrderEntity.setRechargeAmount(new BigDecimal(i));
|
||||
@@ -487,9 +510,72 @@ public class MyUserController {
|
||||
// payPaymentOrderEntity.setRechargeStatus("success");
|
||||
// payPaymentOrderEntity.setSuccessTime(new Date());
|
||||
// payPaymentOrderService.save(payPaymentOrderEntity);
|
||||
|
||||
userService.updateById(byId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 使用虚拟币开通vip
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/openVipByVirtualCoin")
|
||||
public R openVipByVirtualCoin(@RequestParam Map<String,Object> params){
|
||||
|
||||
Integer configId = Integer.valueOf(params.get("configId").toString());
|
||||
String orderSn = params.get("orderSn").toString();
|
||||
Integer userId = Integer.valueOf(params.get("userId").toString());
|
||||
// 根据userId查找用户信息
|
||||
MyUserEntity user = this.userService.getById(userId);
|
||||
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(configId);
|
||||
String month = bookBuyConfigEntity.getMonth();
|
||||
BigDecimal amount = new BigDecimal(bookBuyConfigEntity.getRealMoney());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(user.getPeanutCoin().compareTo(amount) >= 0){
|
||||
user.setPeanutCoin(user.getPeanutCoin().subtract(amount));
|
||||
|
||||
this.userService.updateById(user);
|
||||
// 添加消费信息
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setRemark("购买"+bookBuyConfigEntity.getType()+",金额"+bookBuyConfigEntity.getMoney());
|
||||
transactionDetailsEntity.setUserId(user.getId());
|
||||
transactionDetailsEntity.setUserName(user.getNickname());
|
||||
transactionDetailsEntity.setChangeAmount(amount.negate());
|
||||
transactionDetailsEntity.setUserBalance(user.getPeanutCoin());
|
||||
transactionDetailsEntity.setTel(user.getTel());
|
||||
transactionDetailsEntity.setOrderType("购买会员!");
|
||||
transactionDetailsService.save(transactionDetailsEntity);
|
||||
userService.openMember(userId,Integer.valueOf(month));
|
||||
// 插入 开通记录
|
||||
buyOrderService.updateOrderStatus(userId,orderSn,"2");
|
||||
}else{
|
||||
return R.error(500,"余额不足,请检查后操作!");
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description: app微信登陆
|
||||
* @Author: z.hw
|
||||
*/
|
||||
@RequestMapping("/appUserAuthorLogin")
|
||||
// @ApiOperation(value = "getUserInfoByAppCode", notes = "不分页", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(code = 404, message = "Not Found"),
|
||||
// @ApiResponse(code = 400, message = "No Name Provided"),
|
||||
// })
|
||||
public R getUserInfoByApp(@Validated @RequestBody UserAppAuthorEntity userAppAuthorEntity) {
|
||||
|
||||
return userService.getUserInfoByApp(userAppAuthorEntity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user