bug--代码规范优化,升级fastjson1.2.73

This commit is contained in:
taochengbo
2020-08-29 16:17:15 +08:00
parent 574c7219ac
commit 0f05897962
64 changed files with 727 additions and 275 deletions

View File

@ -38,7 +38,7 @@
<jedis.version>2.9.0</jedis.version>
<log4jdbc.version>1.16</log4jdbc.version>
<swagger.version>2.9.2</swagger.version>
<fastjson.version>1.2.70</fastjson.version>
<fastjson.version>1.2.73</fastjson.version>
<druid.version>1.1.10</druid.version>
<hutool.version>5.2.5</hutool.version>
<commons-pool2.version>2.5.0</commons-pool2.version>

View File

@ -46,7 +46,9 @@ public class RedisServiceImpl implements RedisService {
continue;
}
DataType dataType = redisTemplate.type(s.toString());
if(!dataType.code().equals("string")) continue;
if(!"string".equals(dataType.code())) {
continue;
}
RedisVo redisVo = new RedisVo(s.toString(),redisTemplate.opsForValue().get(s.toString()).toString());
redisVos.add(redisVo);
}

View File

@ -133,7 +133,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, Dept> implement
if(isChild) {
depts.add(deptDto);
for (Dept dept : deptList) {
if(dept.getId() == deptDto.getPid() && !deptNames.contains(dept.getName())){
if(dept.getId().equals(deptDto.getPid()) && !deptNames.contains(dept.getName())){
depts.add(deptDto);
}
}

View File

@ -72,7 +72,7 @@ public class JobServiceImpl extends BaseServiceImpl<JobMapper, Job> implements J
//断权限范围
for (Long deptId : criteria.getDeptIds()) {
for (Job job : jobList) {
if(deptId ==job.getDeptId()){
if(deptId.equals(job.getDeptId())){
job.setDept(deptService.getById(job.getDeptId()));
}
}

View File

@ -315,7 +315,9 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, Menu> implement
if(StringUtils.isNotBlank(resources.getComponentName())&&resources.getType()!=0){
int menuCount = this.lambdaQuery().eq(Menu::getComponentName,resources.getComponentName()).count();
if(menuCount > 1) throw new YshopException("请保持菜单组件名称唯一");
if(menuCount > 1) {
throw new YshopException("请保持菜单组件名称唯一");
}
menu1 = this.getOne(new QueryWrapper<Menu>().lambda()
.eq(Menu::getComponentName,resources.getComponentName()));
if(menu1 != null && !menu1.getId().equals(menu.getId())){

View File

@ -144,7 +144,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, User> imp
public UserDto findByName(String userName) {
User user = userMapper.findByName(userName);
if(user == null) throw new YshopException("当前用户不存在");
if(user == null) {
throw new YshopException("当前用户不存在");
}
//用户所属岗位
user.setJob(jobService.getById(user.getJobId()));
//用户所属部门

View File

@ -62,7 +62,9 @@ public class GlobalExceptionHandler {
Collections.sort(list);
String msg = "不能为空";
if(!list.isEmpty()) msg = list.get(0);
if(!list.isEmpty()) {
msg = list.get(0);
}
log.error(getApiCodeString(ApiCode.PARAMETER_EXCEPTION) + ":" + JSON.toJSONString(list));
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION.getCode(), msg);
}

View File

@ -88,7 +88,9 @@ public class PermissionInterceptor extends HandlerInterceptorAdapter {
Integer uid = map.get("uid").asInt();
Integer scope = map.get("scope").asInt();
YxUser user = userService.getById(uid);
if(user == null) throw new UnAuthenticatedException(ApiCode.NOT_PERMISSION);
if(user == null) {
throw new UnAuthenticatedException(ApiCode.NOT_PERMISSION);
}
LocalUser.set(user, scope);
}

View File

@ -26,8 +26,9 @@ public class JacksonUtil {
try {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return leaf.asText();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -42,9 +43,10 @@ public class JacksonUtil {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return mapper.convertValue(leaf, new TypeReference<List<String>>() {
});
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -57,8 +59,9 @@ public class JacksonUtil {
try {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return leaf.asInt();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -72,9 +75,10 @@ public class JacksonUtil {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return mapper.convertValue(leaf, new TypeReference<List<Integer>>() {
});
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -88,8 +92,9 @@ public class JacksonUtil {
try {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return leaf.asBoolean();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}

View File

@ -34,7 +34,7 @@ public class SmsUtils {
@Autowired
public SmsUtils(RedisUtils redisUtils){
this.redisUtils = redisUtils;
SmsUtils.redisUtils = redisUtils;
}
/**
* 发送短信

View File

@ -106,7 +106,9 @@ public class StoreBargainController {
@GetMapping("/bargain/detail/{id}")
@ApiOperation(value = "砍价详情",notes = "砍价详情",response = YxStoreBargainQueryVo.class)
public ApiResult<BargainVo> getYxStoreBargain(@PathVariable Long id){
if(ObjectUtil.isNull(id)) throw new YshopException("参数错误");
if(ObjectUtil.isNull(id)) {
throw new YshopException("参数错误");
}
YxUser yxUser = LocalUser.getUser();
return ApiResult.ok(storeBargainService.getDetail(id,yxUser));
}
@ -270,7 +272,9 @@ public class StoreBargainController {
Long uid = LocalUser.getUser().getUid();
List<YxStoreBargainUserQueryVo> yxStoreBargainUserQueryVos = storeBargainUserService
.bargainUserList(uid,page,limit);
if(yxStoreBargainUserQueryVos.isEmpty()) throw new YshopException("暂无参与砍价");
if(yxStoreBargainUserQueryVos.isEmpty()) {
throw new YshopException("暂无参与砍价");
}
return ApiResult.ok(yxStoreBargainUserQueryVos);
}

View File

@ -91,7 +91,9 @@ public class StoreCombinationController {
@GetMapping("/combination/detail/{id}")
@ApiOperation(value = "拼团产品详情",notes = "拼团产品详情")
public ApiResult<StoreCombinationVo> detail(@PathVariable Long id){
if(ObjectUtil.isNull(id)) throw new YshopException("参数错误");
if(ObjectUtil.isNull(id)) {
throw new YshopException("参数错误");
}
Long uid = LocalUser.getUser().getUid();
StoreCombinationVo storeCombinationVo = storeCombinationService.getDetail(id,uid);
storeCombinationVo.setUserCollect(relationService
@ -106,7 +108,9 @@ public class StoreCombinationController {
@GetMapping("/combination/pink/{id}")
@ApiOperation(value = "拼团明细",notes = "拼团明细")
public ApiResult<PinkInfoVo> pink(@PathVariable Long id){
if(ObjectUtil.isNull(id)) throw new YshopException("参数错误");
if(ObjectUtil.isNull(id)) {
throw new YshopException("参数错误");
}
Long uid = LocalUser.getUser().getUid();
return ApiResult.ok(storePinkService.pinkInfo(id,uid));
}

View File

@ -118,7 +118,7 @@ public class StoreSeckillController {
SimpleDateFormat sdf = new SimpleDateFormat("HH");
String nowTime = sdf.format(new Date());
String index = nowTime.substring(0, 1);
int currentHour = index.equals("0") ? Integer.valueOf(nowTime.substring(1, 2)) : Integer.valueOf(nowTime);
int currentHour = "0".equals(index) ? Integer.valueOf(nowTime.substring(1, 2)) : Integer.valueOf(nowTime);
SeckillTimeDto seckillTimeDto = new SeckillTimeDto();
seckillTimeDto.setId(i.getId());
//活动结束时间

View File

@ -143,7 +143,9 @@ public class AuthController {
.eq(YxUser::getUsername,loginDTO.getUsername())
.eq(YxUser::getPassword,SecureUtil.md5(loginDTO.getPassword())),false);
if(yxUser == null) throw new YshopException("账号或者密码不正确");
if(yxUser == null) {
throw new YshopException("账号或者密码不正确");
}
String token = JwtToken.makeToken(yxUser.getUid());
String expiresTimeStr = JwtToken.getExpireTime(token);

View File

@ -106,7 +106,9 @@ public class ShoperController {
@GetMapping("/admin/order/detail/{key}")
@ApiOperation(value = "订单详情",notes = "订单详情")
public ApiResult<YxStoreOrderQueryVo> orderDetail(@PathVariable String key){
if(StrUtil.isEmpty(key)) throw new YshopException("参数错误");
if(StrUtil.isEmpty(key)) {
throw new YshopException("参数错误");
}
YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key,null);
if(ObjectUtil.isNull(storeOrder)){
throw new YshopException("订单不存在");

View File

@ -155,7 +155,9 @@ public class StoreOrderController {
//创建订单
YxStoreOrder order = storeOrderService.createOrder(yxUser,key,param);
if(ObjectUtil.isNull(order)) throw new YshopException("订单生成失败");
if(ObjectUtil.isNull(order)) {
throw new YshopException("订单生成失败");
}
String orderId = order.getOrderId();
@ -190,7 +192,9 @@ public class StoreOrderController {
Long uid = LocalUser.getUser().getUid();
YxStoreOrderQueryVo storeOrder = storeOrderService
.getOrderInfo(param.getUni(),uid);
if(ObjectUtil.isNull(storeOrder)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(storeOrder)) {
throw new YshopException("订单不存在");
}
if(OrderInfoEnum.REFUND_STATUS_1.getValue().equals(storeOrder.getPaid())) {
throw new YshopException("该订单已支付");
@ -245,7 +249,9 @@ public class StoreOrderController {
@ApiOperation(value = "订单详情",notes = "订单详情")
public ApiResult<YxStoreOrderQueryVo> detail(@PathVariable String key){
Long uid = LocalUser.getUser().getUid();
if(StrUtil.isEmpty(key)) throw new YshopException("参数错误");
if(StrUtil.isEmpty(key)) {
throw new YshopException("参数错误");
}
YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key,uid);
if(ObjectUtil.isNull(storeOrder)){
throw new YshopException("订单不存在");
@ -363,7 +369,9 @@ public class StoreOrderController {
ExpressService expressService = ExpressAutoConfiguration.expressService();
ExpressInfo expressInfo = expressService.getExpressInfo(expressInfoDo.getOrderCode(),
expressInfoDo.getShipperCode(), expressInfoDo.getLogisticCode());
if(!expressInfo.isSuccess()) throw new YshopException(expressInfo.getReason());
if(!expressInfo.isSuccess()) {
throw new YshopException(expressInfo.getReason());
}
return ApiResult.ok(expressInfo);
}
@ -378,7 +386,9 @@ public class StoreOrderController {
Long uid = LocalUser.getUser().getUid();
YxStoreOrderQueryVo orderQueryVo = storeOrderService.verificOrder(param.getVerifyCode(),
param.getIsConfirm(),uid);
if(orderQueryVo != null) return ApiResult.ok(orderQueryVo);
if(orderQueryVo != null) {
return ApiResult.ok(orderQueryVo);
}
return ApiResult.ok("核销成功");
}

View File

@ -225,7 +225,9 @@ public class StoreProductController {
@ApiOperation(value = "添加收藏",notes = "添加收藏")
public ApiResult<Boolean> collectAdd(@Validated @RequestBody YxStoreProductRelationQueryParam param){
long uid = LocalUser.getUser().getUid();
if(!NumberUtil.isNumber(param.getId())) throw new YshopException("参数非法");
if(!NumberUtil.isNumber(param.getId())) {
throw new YshopException("参数非法");
}
productRelationService.addRroductRelation(Long.valueOf(param.getId()),uid);
return ApiResult.ok();
}
@ -239,7 +241,9 @@ public class StoreProductController {
@ApiOperation(value = "取消收藏",notes = "取消收藏")
public ApiResult<Boolean> collectDel(@Validated @RequestBody YxStoreProductRelationQueryParam param){
long uid = LocalUser.getUser().getUid();
if(!NumberUtil.isNumber(param.getId())) throw new YshopException("参数非法");
if(!NumberUtil.isNumber(param.getId())) {
throw new YshopException("参数非法");
}
productRelationService.delRroductRelation(Long.valueOf(param.getId()),
uid);
return ApiResult.ok();

View File

@ -79,7 +79,9 @@ public class CreatShareProductService {
//门店
if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(storeOrder.getShippingType())){
String mapKey = RedisUtil.get(SystemConfigConstants.TENGXUN_MAP_KEY);
if(StrUtil.isBlank(mapKey)) throw new YshopException("请配置腾讯地图key");
if(StrUtil.isBlank(mapKey)) {
throw new YshopException("请配置腾讯地图key");
}
String apiUrl = systemConfigService.getData(SystemConfigConstants.API_URL);
if(StrUtil.isEmpty(apiUrl)){
throw new YshopException("未配置api地址");
@ -463,9 +465,13 @@ public class CreatShareProductService {
String apiUrl,String path){
Long uid = userInfo.getUid();
YxStorePink storePink = storePinkService.getById(pinkId);
if(ObjectUtil.isNull(storePink)) throw new YshopException("拼团不存在");
if(ObjectUtil.isNull(storePink)) {
throw new YshopException("拼团不存在");
}
YxStoreCombination storeCombination = storeCombinationService.getById(storePink.getCid());
if(ObjectUtil.isNull(storeCombination)) throw new YshopException("拼团产品不存在");
if(ObjectUtil.isNull(storeCombination)) {
throw new YshopException("拼团产品不存在");
}
String userType = userInfo.getUserType();
if(StrUtil.isBlank(userType)) {

View File

@ -105,7 +105,9 @@ public class OrderSupplyService {
*/
public Map<String,Object> check(Long uid,String key, ComputeOrderParam param){
Map<String,Object> map = Maps.newHashMap();
if(StrUtil.isBlank(key)) throw new YshopException("参数错误");
if(StrUtil.isBlank(key)) {
throw new YshopException("参数错误");
}
YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key,uid);
if(ObjectUtil.isNotNull(storeOrder)){
@ -124,7 +126,9 @@ public class OrderSupplyService {
if(bargainId > 0){
YxStoreBargainUser storeBargainUser = storeBargainUserService
.getBargainUserInfo(bargainId,uid);
if(storeBargainUser == null) throw new YshopException("砍价失败");
if(storeBargainUser == null) {
throw new YshopException("砍价失败");
}
if(OrderInfoEnum.BARGAIN_STATUS_3.getValue().equals(storeBargainUser.getStatus())) {
throw new YshopException("砍价已支付");
}

View File

@ -176,7 +176,9 @@ public class UserBillController {
@RequestParam(value = "limit",defaultValue = "10") int limit,
@PathVariable String type){
int newType = 0;
if(NumberUtil.isNumber(type)) newType = Integer.valueOf(type);
if(NumberUtil.isNumber(type)) {
newType = Integer.valueOf(type);
}
Long uid = LocalUser.getUser().getUid();
return ApiResult.ok(userBillService.getUserBillList(page,limit,uid,newType));
}

View File

@ -98,7 +98,9 @@ public class UserRechargeController {
Map<String,Object> map = new LinkedHashMap<>();
map.put("type",param.getFrom());
YxSystemGroupData systemGroupData = systemGroupDataService.getById(param.getRecharId());
if(systemGroupData == null) throw new YshopException("充值方案不存在");
if(systemGroupData == null) {
throw new YshopException("充值方案不存在");
}
JSONObject jsonObject = JSON.parseObject(systemGroupData.getValue());
String price = jsonObject.getString("price");

View File

@ -134,14 +134,20 @@ public class WechatController {
public String renotify(@RequestBody String xmlData) {
try {
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
if(wxPayService == null) wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
if(wxPayService == null) wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP);
if(wxPayService == null) {
wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
}
if(wxPayService == null) {
wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP);
}
WxPayOrderNotifyResult notifyResult = wxPayService.parseOrderNotifyResult(xmlData);
String orderId = notifyResult.getOutTradeNo();
String attach = notifyResult.getAttach();
if(BillDetailEnum.TYPE_3.getValue().equals(attach)){
YxStoreOrderQueryVo orderInfo = orderService.getOrderInfo(orderId,null);
if(orderInfo == null) return WxPayNotifyResponse.success("处理成功!");
if(orderInfo == null) {
return WxPayNotifyResponse.success("处理成功!");
}
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())){
return WxPayNotifyResponse.success("处理成功!");
}
@ -149,7 +155,9 @@ public class WechatController {
}else if(BillDetailEnum.TYPE_1.getValue().equals(attach)){
//处理充值
YxUserRecharge userRecharge = userRechargeService.getInfoByOrderId(orderId);
if(userRecharge == null) return WxPayNotifyResponse.success("处理成功!");
if(userRecharge == null) {
return WxPayNotifyResponse.success("处理成功!");
}
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(userRecharge.getPaid())){
return WxPayNotifyResponse.success("处理成功!");
}
@ -173,8 +181,12 @@ public class WechatController {
public String parseRefundNotifyResult(@RequestBody String xmlData) {
try {
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
if(wxPayService == null) wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
if(wxPayService == null) wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP);
if(wxPayService == null) {
wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
}
if(wxPayService == null) {
wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP);
}
WxPayRefundNotifyResult result = wxPayService.parseRefundNotifyResult(xmlData);
String orderId = result.getReqInfo().getOutTradeNo();
BigDecimal refundFee = BigNum.div(result.getReqInfo().getRefundFee(), 100);
@ -242,14 +254,18 @@ public class WechatController {
// 明文传输的消息
WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody);
WxMpXmlOutMessage outMessage = this.route(inMessage);
if(outMessage == null) return;
if(outMessage == null) {
return;
}
out = outMessage.toXml();;
} else if ("aes".equalsIgnoreCase(encType)) {
// aes加密的消息
WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, wxService.getWxMpConfigStorage(),
timestamp, nonce, msgSignature);
WxMpXmlOutMessage outMessage = this.route(inMessage);
if(outMessage == null) return;
if(outMessage == null) {
return;
}
out = outMessage.toEncryptedXml(wxService.getWxMpConfigStorage());
}

View File

@ -169,5 +169,7 @@ public interface ShopConstants {
String YSHOP_APP_LOGIN_USER = "app-online-token";
String YSHOP_WECHAT_PUSH_REMARK = "yshop为您服务";
}

View File

@ -569,8 +569,9 @@ public class PrintUtil4 {
* @return
*/
public static String substring(String str, int f, int t) {
if (f > str.length())
if (f > str.length()) {
return null;
}
if (t > str.length()) {
return str.substring(f, str.length());
} else {

View File

@ -27,7 +27,7 @@ public class OrderUtil {
* @return
**/
public static int getSecondTimestamp(){
String timestamp = String.valueOf(new Date().getTime()/1000);
String timestamp = String.valueOf(System.currentTimeMillis()/1000);
return Integer.valueOf(timestamp);
}
@ -42,7 +42,9 @@ public class OrderUtil {
public static String checkActivityStatus(Date starTime,Date endTime,Integer status){
Date nowTime = new Date();
if(ShopCommonEnum.IS_STATUS_0.getValue().equals(status)) return "关闭";
if(ShopCommonEnum.IS_STATUS_0.getValue().equals(status)) {
return "关闭";
}
if(DateUtil.compare(starTime,nowTime) > 0){
return "活动未开始";
@ -131,7 +133,7 @@ public class OrderUtil {
* @return
**/
public static int getSecondTimestampTwo() {
String timestamp = String.valueOf(new Date().getTime() / 1000);
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
return Integer.valueOf(timestamp);
}

View File

@ -96,7 +96,9 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl<YxStoreBargainMap
@Override
public void decStockIncSales(int num, Long bargainId) {
int res = yxStoreBargainMapper.decStockIncSales(num,bargainId);
if(res == 0) throw new YshopException("砍价产品库存不足");
if(res == 0) {
throw new YshopException("砍价产品库存不足");
}
}
// @Override
@ -133,14 +135,18 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl<YxStoreBargainMap
//用户剩余要砍掉的价格
double surplusPrice = NumberUtil.sub(coverPrice,
storeBargainUser.getPrice()).doubleValue();
if(surplusPrice == 0) return;
if(surplusPrice == 0) {
return;
}
//生成一个区间随机数
random = OrderUtil.randomNumber(
storeBargain.getBargainMinPrice().doubleValue(),
storeBargain.getBargainMaxPrice().doubleValue());
if(random > surplusPrice) random = surplusPrice;
if(random > surplusPrice) {
random = surplusPrice;
}
}
@ -174,7 +180,9 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl<YxStoreBargainMap
*/
@Override
public TopCountVo topCount(Long bargainId) {
if(bargainId != null) this.addBargainShare(bargainId);
if(bargainId != null) {
this.addBargainShare(bargainId);
}
return TopCountVo.builder()
.lookCount(yxStoreBargainMapper.lookCount())
.shareCount(yxStoreBargainMapper.shareCount())
@ -214,7 +222,9 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl<YxStoreBargainMap
.eq(YxStoreBargainUserHelp::getUid,myUid)
.count();
if(helpCount > 0) userBargainStatus = false;
if(helpCount > 0) {
userBargainStatus = false;
}
int count = storeBargainUserHelpService
@ -268,7 +278,9 @@ public class YxStoreBargainServiceImpl extends BaseServiceImpl<YxStoreBargainMap
.ge(YxStoreBargain::getStopTime,now)
.one();
if(storeBargain == null) throw new YshopException("砍价已结束");
if(storeBargain == null) {
throw new YshopException("砍价已结束");
}
this.addBargainLook(id);

View File

@ -65,12 +65,18 @@ public class YxStoreBargainUserServiceImpl extends BaseServiceImpl<YxStoreBargai
@Override
public void setBargainUserStatus(Long bargainId, Long uid) {
YxStoreBargainUser storeBargainUser = getBargainUserInfo(bargainId.longValue(),uid);
if(ObjectUtil.isNull(storeBargainUser)) return;
if(ObjectUtil.isNull(storeBargainUser)) {
return;
}
if(storeBargainUser.getStatus() != 1) return;
if(storeBargainUser.getStatus() != 1) {
return;
}
double price = NumberUtil.sub(NumberUtil.sub(storeBargainUser.getBargainPrice(),
storeBargainUser.getBargainPriceMin()),storeBargainUser.getPrice()).doubleValue();
if(price > 0) return;
if(price > 0) {
return;
}
storeBargainUser.setStatus(3);
@ -85,7 +91,9 @@ public class YxStoreBargainUserServiceImpl extends BaseServiceImpl<YxStoreBargai
@Override
public void bargainCancel(Long bargainId, Long uid) {
YxStoreBargainUser storeBargainUser = this.getBargainUserInfo(bargainId,uid);
if(ObjectUtil.isNull(storeBargainUser)) throw new YshopException("数据不存在");
if(ObjectUtil.isNull(storeBargainUser)) {
throw new YshopException("数据不存在");
}
if(!OrderInfoEnum.BARGAIN_STATUS_1.getValue().equals(storeBargainUser.getStatus())){
throw new YshopException("状态错误");
}
@ -125,7 +133,9 @@ public class YxStoreBargainUserServiceImpl extends BaseServiceImpl<YxStoreBargai
.eq(YxStoreBargainUserHelp::getBargainUserId,storeBargainUser.getId())
.eq(YxStoreBargainUserHelp::getUid,uid)
.count();
if(count == 0) return true;
if(count == 0) {
return true;
}
return false;
}
@ -137,9 +147,13 @@ public class YxStoreBargainUserServiceImpl extends BaseServiceImpl<YxStoreBargai
@Override
public void setBargain(Long bargainId, Long uid) {
YxStoreBargainUser storeBargainUser = this.getBargainUserInfo(bargainId,uid);
if(storeBargainUser != null) throw new YshopException("你已经参与了");
if(storeBargainUser != null) {
throw new YshopException("你已经参与了");
}
YxStoreBargain storeBargain = storeBargainService.getById(bargainId);
if(storeBargain == null) throw new YshopException("砍价商品不存在");
if(storeBargain == null) {
throw new YshopException("砍价商品不存在");
}
YxStoreBargainUser yxStoreBargainUser = YxStoreBargainUser
.builder()
.bargainId(bargainId)

View File

@ -105,7 +105,9 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
@Override
public void decStockIncSales(int num, Long combinationId) {
int res = yxStoreCombinationMapper.decStockIncSales(num,combinationId);
if(res == 0) throw new YshopException("拼团产品库存不足");
if(res == 0) {
throw new YshopException("拼团产品库存不足");
}
}
/**
@ -315,7 +317,9 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
//添加商品
YxStoreCombination yxStoreCombination = new YxStoreCombination();
BeanUtil.copyProperties(resources,yxStoreCombination,"images");
if(resources.getImages().isEmpty()) throw new YshopException("请上传轮播图");
if(resources.getImages().isEmpty()) {
throw new YshopException("请上传轮播图");
}
yxStoreCombination.setPrice(BigDecimal.valueOf(resultDTO.getMinPrice()));
yxStoreCombination.setCost(resultDTO.getMinCost().intValue());
@ -379,7 +383,9 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
.reduce(Integer::sum)
.orElse(0);
if(stock <= 0) throw new YshopException("库存不能低于0");
if(stock <= 0) {
throw new YshopException("库存不能低于0");
}
return ProductResultDto.builder()
.minPrice(minPrice)

View File

@ -68,10 +68,14 @@ public class YxStoreCouponIssueServiceImpl extends BaseServiceImpl<YxStoreCoupon
public void issueUserCoupon(Integer id, Long uid) {
YxStoreCouponIssueQueryVo couponIssueQueryVo = yxStoreCouponIssueMapper
.selectOne(id);
if(ObjectUtil.isNull(couponIssueQueryVo)) throw new YshopException("领取的优惠劵已领完或已过期");
if(ObjectUtil.isNull(couponIssueQueryVo)) {
throw new YshopException("领取的优惠劵已领完或已过期");
}
int count = this.couponCount(id,uid);
if(count > 0) throw new YshopException("已领取过该优惠劵");
if(count > 0) {
throw new YshopException("已领取过该优惠劵");
}
if(couponIssueQueryVo.getRemainCount() <= 0
&& CouponEnum.PERMANENT_0.getValue().equals(couponIssueQueryVo.getIsPermanent())){
@ -100,7 +104,9 @@ public class YxStoreCouponIssueServiceImpl extends BaseServiceImpl<YxStoreCoupon
public List<YxStoreCouponIssueQueryVo> getCouponList(int page, int limit, Long uid,Long productId,Integer type) {
Page<YxStoreCouponIssue> pageModel = new Page<>(page, limit);
if(type == null) type = CouponEnum.TYPE_0.getValue();
if(type == null) {
type = CouponEnum.TYPE_0.getValue();
}
List<YxStoreCouponIssueQueryVo> list = yxStoreCouponIssueMapper
.selecCoupontList(pageModel,type,productId);
for (YxStoreCouponIssueQueryVo couponIssue : list) {

View File

@ -179,7 +179,7 @@ public class YxStoreCouponUserServiceImpl extends BaseServiceImpl<YxStoreCouponU
.selectList(Wrappers.<YxStoreCouponUser>lambdaQuery()
.eq(YxStoreCouponUser::getUid,uid));
List<YxStoreCouponUserQueryVo> storeCouponUserQueryVoList = new ArrayList<>();
long nowTime = new Date().getTime();
long nowTime = System.currentTimeMillis();
for (YxStoreCouponUser couponUser : storeCouponUsers) {
YxStoreCouponUserQueryVo queryVo = generator.convert(couponUser,YxStoreCouponUserQueryVo.class);
if(couponUser.getIsFail() == 1){
@ -212,7 +212,9 @@ public class YxStoreCouponUserServiceImpl extends BaseServiceImpl<YxStoreCouponU
@Override
public void addUserCoupon(Long uid, Integer cid) {
YxStoreCoupon storeCoupon = storeCouponService.getById(cid);
if(storeCoupon == null) throw new YshopException("优惠劵不存在");
if(storeCoupon == null) {
throw new YshopException("优惠劵不存在");
}
Date now = new Date();
@ -240,7 +242,9 @@ public class YxStoreCouponUserServiceImpl extends BaseServiceImpl<YxStoreCouponU
* @return boolean
*/
private boolean isSame(List<String> list1,List<String> list2){
if(list2.isEmpty()) return true;
if(list2.isEmpty()) {
return true;
}
list1 = new ArrayList<>(list1);
list2 = new ArrayList<>(list2);
list1.addAll(list2);

View File

@ -104,7 +104,9 @@ public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, Y
.eq(YxStorePink::getStatus,OrderInfoEnum.REFUND_STATUS_1.getValue())
.gt(YxStorePink::getStopTime,new Date())
.one();
if(pink == null) throw new YshopException("拼团不存在或已经取消");
if(pink == null) {
throw new YshopException("拼团不存在或已经取消");
}
PinkUserDto pinkUserDto = this.getPinkMemberAndPinK(pink);
List<YxStorePink> pinkAll = pinkUserDto.getPinkAll();
@ -156,6 +158,7 @@ public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, Y
* @param pink 拼团信息
* @return int
*/
@Override
public int surplusPeople(YxStorePink pink) {
List<YxStorePink> listT = new ArrayList<>();
if(pink.getKId() > 0){ //团长存在
@ -178,7 +181,9 @@ public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, Y
@Override
public PinkInfoVo pinkInfo(Long id, Long uid) {
YxStorePink pink = this.getPinkUserOne(id);
if(ObjectUtil.isNull(pink)) throw new YshopException("拼团不存在");
if(ObjectUtil.isNull(pink)) {
throw new YshopException("拼团不存在");
}
if( OrderInfoEnum.PINK_REFUND_STATUS_1.getValue().equals(pink.getIsRefund())){
throw new YshopException("订单已退款");
}
@ -194,7 +199,9 @@ public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, Y
List<Long> uidAll = pinkUserDto.getUidAll();
int count = pinkUserDto.getCount();
if(count < 0) count = 0;
if(count < 0) {
count = 0;
}
if(OrderInfoEnum.PINK_STATUS_2.getValue().equals(pinkT.getStatus())){
pinkBool = PinkEnum.PINK_BOOL_1.getValue();
isOk = PinkEnum.IS_OK_1.getValue();
@ -213,14 +220,20 @@ public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, Y
//团员是否在团
if(ObjectUtil.isNotNull(pinkAll)){
for (YxStorePink storePink : pinkAll) {
if(storePink.getUid().equals(uid)) userBool = PinkEnum.USER_BOOL_1.getValue();
if(storePink.getUid().equals(uid)) {
userBool = PinkEnum.USER_BOOL_1.getValue();
}
}
}
//团长
if(pinkT.getUid().equals(uid)) userBool = PinkEnum.USER_BOOL_1.getValue();
if(pinkT.getUid().equals(uid)) {
userBool = PinkEnum.USER_BOOL_1.getValue();
}
YxStoreCombinationQueryVo storeCombinationQueryVo = yxStoreCombinationMapper.getCombDetail(pink.getCid());
if(ObjectUtil.isNull(storeCombinationQueryVo)) throw new YshopException("拼团不存在或已下架");
if(ObjectUtil.isNull(storeCombinationQueryVo)) {
throw new YshopException("拼团不存在或已下架");
}
YxUserQueryVo userInfo = userService.getYxUserById(uid);
@ -265,7 +278,9 @@ public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, Y
order = storeOrderService.handleOrder(order);
int pinkCount = yxStorePinkMapper.selectCount(Wrappers.<YxStorePink>lambdaQuery()
.eq(YxStorePink::getOrderId,order.getOrderId()));
if(pinkCount > 0) return;
if(pinkCount > 0) {
return;
}
if(storeCombination != null){
YxStorePink storePink = YxStorePink.builder()
.uid(order.getUid())
@ -285,7 +300,9 @@ public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, Y
storePink.setPeople(storeCombination.getPeople());
storePink.setStopTime(stopTime);
if(order.getPinkId() > 0){ //其他成员入团
if(this.getIsPinkUid(order.getPinkId(),order.getUid())) return;
if(this.getIsPinkUid(order.getPinkId(),order.getUid())) {
return;
}
storePink.setKId(order.getPinkId());
storePink.setStopTime(null);
this.save(storePink);
@ -434,7 +451,9 @@ public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, Y
if(pink == null){
pink = yxStorePinkMapper.selectOne(Wrappers.<YxStorePink>lambdaQuery()
.eq(YxStorePink::getKId,id).eq(YxStorePink::getUid,uid));
if(pink == null) return "";
if(pink == null) {
return "";
}
}
return pink.getOrderId();
}
@ -471,7 +490,9 @@ public class YxStorePinkServiceImpl extends BaseServiceImpl<YxStorePinkMapper, Y
int count = this.lambdaQuery().in(YxStorePink::getId,idAll)
.eq(YxStorePink::getIsRefund,OrderInfoEnum.PINK_REFUND_STATUS_1.getValue())
.count();
if(count == 0) return true;
if(count == 0) {
return true;
}
return false;
}

View File

@ -96,7 +96,9 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
@Override
public void decStockIncSales(int num, Long seckillId) {
int res = yxStoreSeckillMapper.decStockIncSales(num,seckillId);
if(res == 0) throw new YshopException("秒杀产品库存不足");
if(res == 0) {
throw new YshopException("秒杀产品库存不足");
}
}
// @Override
@ -245,7 +247,9 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
//添加商品
YxStoreSeckill yxStoreSeckill = new YxStoreSeckill();
BeanUtil.copyProperties(resources,yxStoreSeckill,"images");
if(resources.getImages().isEmpty()) throw new YshopException("请上传轮播图");
if(resources.getImages().isEmpty()) {
throw new YshopException("请上传轮播图");
}
yxStoreSeckill.setPrice(BigDecimal.valueOf(resultDTO.getMinPrice()));
yxStoreSeckill.setCost(new BigDecimal(resultDTO.getMinCost()));
@ -308,7 +312,9 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
.reduce(Integer::sum)
.orElse(0);
if(stock <= 0) throw new YshopException("库存不能低于0");
if(stock <= 0) {
throw new YshopException("库存不能低于0");
}
return ProductResultDto.builder()
.minPrice(minPrice)

View File

@ -68,15 +68,23 @@ public class YxUserExtractServiceImpl extends BaseServiceImpl<YxUserExtractMappe
@Override
public void userExtract(YxUser userInfo, UserExtParam param) {
BigDecimal extractPrice = userInfo.getBrokeragePrice();
if(extractPrice.compareTo(BigDecimal.ZERO) <= 0) throw new YshopException("提现佣金不足");
if(extractPrice.compareTo(BigDecimal.ZERO) <= 0) {
throw new YshopException("提现佣金不足");
}
double money = Double.valueOf(param.getMoney());
if( extractPrice.compareTo(BigDecimal.valueOf(money)) < 0) throw new YshopException("提现佣金不足");
if( extractPrice.compareTo(BigDecimal.valueOf(money)) < 0) {
throw new YshopException("提现佣金不足");
}
if(money <= 0) throw new YshopException("提现佣金大于0");
if(money <= 0) {
throw new YshopException("提现佣金大于0");
}
double balance = NumberUtil.sub(extractPrice.doubleValue(),money);
if(balance < 0) balance = 0;
if(balance < 0) {
balance = 0;
}
YxUserExtract userExtract = new YxUserExtract();
userExtract.setUid(userInfo.getUid());
@ -184,6 +192,7 @@ public class YxUserExtractServiceImpl extends BaseServiceImpl<YxUserExtractMappe
* 操作提现
* @param resources YxUserExtract
*/
@Override
public void doExtract(YxUserExtract resources){
if(resources.getStatus() == null){
throw new BadRequestException("请选择审核状态");

View File

@ -138,7 +138,9 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<StoreCartMapper, YxS
throw new YshopException("该产品库存不足"+cartNum);
}
if(cartNum == cart.getCartNum()) return;
if(cartNum == cart.getCartNum()) {
return;
}
YxStoreCart storeCart = new YxStoreCart();
storeCart.setCartNum(cartNum);
@ -162,8 +164,12 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<StoreCartMapper, YxS
wrapper.lambda().eq(YxStoreCart::getUid,uid)
.eq(YxStoreCart::getIsPay,OrderInfoEnum.PAY_STATUS_0.getValue())
.orderByDesc(YxStoreCart::getId);
if(status == null) wrapper.lambda().eq(YxStoreCart::getIsNew, CartTypeEnum.NEW_0.getValue());
if(StrUtil.isNotEmpty(cartIds)) wrapper.lambda().in(YxStoreCart::getId, Arrays.asList(cartIds.split(",")));
if(status == null) {
wrapper.lambda().eq(YxStoreCart::getIsNew, CartTypeEnum.NEW_0.getValue());
}
if(StrUtil.isNotEmpty(cartIds)) {
wrapper.lambda().in(YxStoreCart::getId, Arrays.asList(cartIds.split(",")));
}
List<YxStoreCart> carts = yxStoreCartMapper.selectList(wrapper);
List<YxStoreCartQueryVo> valid = new ArrayList<>();

View File

@ -130,10 +130,11 @@ public class YxStoreCategoryServiceImpl extends BaseServiceImpl<StoreCategoryMap
deptDTO.getChildren().add(it);
}
}
if (isChild)
if (isChild) {
cates.add(deptDTO);
}
for (YxStoreCategory category : categories) {
if (category.getId() == deptDTO.getPid() && !deptNames.contains(category.getCateName())) {
if (category.getId().equals(deptDTO.getPid()) && !deptNames.contains(category.getCateName())) {
cates.add(deptDTO);
}
}
@ -161,10 +162,14 @@ public class YxStoreCategoryServiceImpl extends BaseServiceImpl<StoreCategoryMap
*/
@Override
public boolean checkCategory(int pid){
if(pid == 0) return true;
if(pid == 0) {
return true;
}
YxStoreCategory yxStoreCategory = this.getOne(Wrappers.<YxStoreCategory>lambdaQuery()
.eq(YxStoreCategory::getId,pid));
if(yxStoreCategory.getPid() > 0) return false;
if(yxStoreCategory.getPid() > 0) {
return false;
}
return true;
}
@ -174,11 +179,14 @@ public class YxStoreCategoryServiceImpl extends BaseServiceImpl<StoreCategoryMap
* @param id 分类id
* @return boolean
*/
@Override
public boolean checkProductCategory(int id){
YxStoreCategory yxStoreCategory = this.getOne(Wrappers.<YxStoreCategory>lambdaQuery()
.eq(YxStoreCategory::getId,id));
if(yxStoreCategory.getPid() == 0) return false;
if(yxStoreCategory.getPid() == 0) {
return false;
}
return true;
}

View File

@ -289,7 +289,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
.getUsableCouponList(uid, priceGroup.getTotalPrice().doubleValue(), productIds);
StoreCouponUserVo storeCouponUser = null;
if(storeCouponUsers != null && !storeCouponUsers.isEmpty()) storeCouponUser = storeCouponUsers.get(0);
if(storeCouponUsers != null && !storeCouponUsers.isEmpty()) {
storeCouponUser = storeCouponUsers.get(0);
}
return ConfirmOrderVo.builder()
.addressInfo(userAddress)
@ -365,7 +367,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
BigDecimal couponPrice = BigDecimal.ZERO;
if(StrUtil.isNotBlank(couponId) && !ShopConstants.YSHOP_ZERO.equals(couponId)){//使用优惠券
YxStoreCouponUser couponUser = couponUserService.getCoupon(Integer.valueOf(couponId),uid);
if(couponUser == null) throw new YshopException("使用优惠劵失败");
if(couponUser == null) {
throw new YshopException("使用优惠劵失败");
}
if(couponUser.getUseMinPrice().compareTo(payPrice) > 0){
throw new YshopException("不满足优惠劵的使用条件");
@ -401,7 +405,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
}
}
if(payPrice.compareTo(BigDecimal.ZERO) <= 0) payPrice = BigDecimal.ZERO;
if(payPrice.compareTo(BigDecimal.ZERO) <= 0) {
payPrice = BigDecimal.ZERO;
}
return ComputeVo.builder()
.totalPrice(cacheDTO.getPriceGroup().getTotalPrice())
@ -434,9 +440,13 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
//处理选择门店与正常选择地址下单
YxUserAddress userAddress = null;
if(OrderInfoEnum.SHIPPIING_TYPE_1.getValue().equals(Integer.valueOf(param.getShippingType()))){
if(StrUtil.isEmpty(param.getAddressId())) throw new YshopException("请选择收货地址");
if(StrUtil.isEmpty(param.getAddressId())) {
throw new YshopException("请选择收货地址");
}
userAddress = userAddressService.getById(param.getAddressId());
if(ObjectUtil.isNull(userAddress)) throw new YshopException("地址选择有误");
if(ObjectUtil.isNull(userAddress)) {
throw new YshopException("地址选择有误");
}
}else{ //门店
if(StrUtil.isBlank(param.getRealName()) || StrUtil.isBlank(param.getPhone())) {
throw new YshopException("请填写姓名和电话");
@ -517,13 +527,17 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
//处理门店
if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().toString().equals(param.getShippingType())){
YxSystemStore systemStoreQueryVo = systemStoreService.getById(param.getStoreId());
if(systemStoreQueryVo == null ) throw new ErrorRequestException("暂无门店无法选择门店自提");
if(systemStoreQueryVo == null ) {
throw new ErrorRequestException("暂无门店无法选择门店自提");
}
storeOrder.setVerifyCode(StrUtil.sub(orderSn,orderSn.length(),-12));
storeOrder.setStoreId(systemStoreQueryVo.getId());
}
boolean res = this.save(storeOrder);
if(!res) throw new YshopException("订单生成失败");
if(!res) {
throw new YshopException("订单生成失败");
}
//使用了积分扣积分
if(computeVo.getUsedIntegral() > 0){
@ -588,12 +602,16 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
.getOne(Wrappers.<YxStoreOrderCartInfo>lambdaQuery()
.eq(YxStoreOrderCartInfo::getUnique,unique));
if(ObjectUtil.isEmpty(orderCartInfo)) throw new YshopException("评价产品不存在");
if(ObjectUtil.isEmpty(orderCartInfo)) {
throw new YshopException("评价产品不存在");
}
int count = productReplyService.count(Wrappers.<YxStoreProductReply>lambdaQuery()
.eq(YxStoreProductReply::getOid,orderCartInfo.getOid())
.eq(YxStoreProductReply::getProductId,orderCartInfo.getProductId()));
if(count > 0) throw new YshopException("该产品已评价");
if(count > 0) {
throw new YshopException("该产品已评价");
}
YxStoreProductReply storeProductReply = YxStoreProductReply.builder()
@ -634,16 +652,22 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
public void orderRefund(String orderId,BigDecimal price,Integer type) {
YxStoreOrderQueryVo orderQueryVo = getOrderInfo(orderId,null);
if(ObjectUtil.isNull(orderQueryVo)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(orderQueryVo)) {
throw new YshopException("订单不存在");
}
YxUserQueryVo userQueryVo = userService.getYxUserById(orderQueryVo.getUid());
if(ObjectUtil.isNull(userQueryVo)) throw new YshopException("用户不存在");
if(ObjectUtil.isNull(userQueryVo)) {
throw new YshopException("用户不存在");
}
if(OrderInfoEnum.REFUND_STATUS_2.getValue().equals(orderQueryVo.getRefundStatus())){
throw new YshopException("订单已经退款了哦!");
}
if(orderQueryVo.getPayPrice().compareTo(price) < 0) throw new YshopException("退款金额不正确");
if(orderQueryVo.getPayPrice().compareTo(price) < 0) {
throw new YshopException("退款金额不正确");
}
YxStoreOrder storeOrder = new YxStoreOrder();
//修改状态
@ -697,7 +721,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
@Override
public void orderDelivery(String orderId,String deliveryId,String deliveryName,String deliveryType) {
YxStoreOrderQueryVo orderQueryVo = this.getOrderInfo(orderId,null);
if(ObjectUtil.isNull(orderQueryVo)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(orderQueryVo)) {
throw new YshopException("订单不存在");
}
if(!OrderInfoEnum.STATUS_0.getValue().equals(orderQueryVo.getStatus()) ||
OrderInfoEnum.PAY_STATUS_0.getValue().equals( orderQueryVo.getPaid())){
@ -705,7 +731,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
}
YxExpress expressQueryVo = expressService.getById(Integer.valueOf(deliveryName));
if(ObjectUtil.isNull(expressQueryVo)) throw new YshopException("请后台先添加快递公司");
if(ObjectUtil.isNull(expressQueryVo)) {
throw new YshopException("请后台先添加快递公司");
}
//判断拼团产品
if(orderQueryVo.getPinkId() != null && orderQueryVo.getPinkId() >0 ){
@ -759,10 +787,14 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
@Override
public void editOrderPrice(String orderId,String price) {
YxStoreOrderQueryVo orderQueryVo = getOrderInfo(orderId,null);
if(ObjectUtil.isNull(orderQueryVo)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(orderQueryVo)) {
throw new YshopException("订单不存在");
}
if(orderQueryVo.getPayPrice().compareTo(new BigDecimal(price)) == 0) return;
if(orderQueryVo.getPayPrice().compareTo(new BigDecimal(price)) == 0) {
return;
}
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderQueryVo.getPaid())) {
@ -811,7 +843,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
@Override
public void cancelOrder(String orderId, Long uid) {
YxStoreOrderQueryVo order = this.getOrderInfo(orderId,uid);
if(ObjectUtil.isNull(order)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(order)) {
throw new YshopException("订单不存在");
}
this.regressionIntegral(order);
@ -834,7 +868,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
@Override
public void removeOrder(String orderId, Long uid) {
YxStoreOrderQueryVo order = getOrderInfo(orderId,(long)uid);
if(order == null) throw new YshopException("订单不存在");
if(order == null) {
throw new YshopException("订单不存在");
}
order = handleOrder(order);
if(!OrderInfoEnum.STATUS_3.getValue().equals(order.getStatus())) {
throw new YshopException("该订单无法删除");
@ -857,7 +893,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
@Override
public void takeOrder(String orderId, Long uid) {
YxStoreOrderQueryVo order = this.getOrderInfo(orderId,uid);
if(ObjectUtil.isNull(order)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(order)) {
throw new YshopException("订单不存在");
}
order = handleOrder(order);
if(!OrderStatusEnum.STATUS_2.getValue().toString().equals(order.get_status().get_type())) {
throw new BusinessException("订单状态错误");
@ -896,14 +934,20 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
.eq(YxStoreOrder::getVerifyCode,verifyCode)
.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue())
.eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()));
if(order == null) throw new YshopException("核销的订单不存在或未支付或已退款");
if(order == null) {
throw new YshopException("核销的订单不存在或未支付或已退款");
}
if(uid != null){
boolean checkStatus = systemStoreStaffService.checkStatus(uid,order.getStoreId());
if(!checkStatus) throw new YshopException("您没有当前店铺核销权限");
if(!checkStatus) {
throw new YshopException("您没有当前店铺核销权限");
}
}
if(!OrderInfoEnum.STATUS_0.getValue().equals(order.getStatus())) throw new YshopException("订单已经核销");
if(!OrderInfoEnum.STATUS_0.getValue().equals(order.getStatus())) {
throw new YshopException("订单已经核销");
}
if(order.getCombinationId() != null && order.getCombinationId() > 0
&& order.getPinkId() != null && order.getPinkId() > 0){
@ -950,7 +994,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
@Override
public void orderApplyRefund(String explain,String Img,String text,String orderId, Long uid) {
YxStoreOrderQueryVo order = getOrderInfo(orderId,uid);
if(order == null) throw new YshopException("订单不存在");
if(order == null) {
throw new YshopException("订单不存在");
}
if(OrderInfoEnum.REFUND_STATUS_2.getValue().equals(order.getRefundStatus())){
throw new YshopException("订单已退款");
@ -958,7 +1004,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
if(OrderInfoEnum.REFUND_STATUS_1.getValue().equals(order.getRefundStatus())) {
throw new YshopException("正在申请退款中");
}
if(OrderInfoEnum.STATUS_1.getValue().equals(order.getStatus())) throw new YshopException("订单当前无法退款");
if(OrderInfoEnum.STATUS_1.getValue().equals(order.getStatus())) {
throw new YshopException("订单当前无法退款");
}
YxStoreOrder storeOrder = new YxStoreOrder();
@ -1174,7 +1222,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
//订单支付没有退款 数量
QueryWrapper<YxStoreOrder> wrapperOne = new QueryWrapper<>();
if(uid != null) wrapperOne.lambda().eq(YxStoreOrder::getUid,uid);
if(uid != null) {
wrapperOne.lambda().eq(YxStoreOrder::getUid,uid);
}
wrapperOne.lambda().eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue())
.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue());
Integer orderCount = yxStoreOrderMapper.selectCount(wrapperOne);
@ -1184,7 +1234,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
//订单待支付 数量
QueryWrapper<YxStoreOrder> wrapperTwo = new QueryWrapper<>();
if(uid != null) wrapperTwo.lambda().eq(YxStoreOrder::getUid,uid);
if(uid != null) {
wrapperTwo.lambda().eq(YxStoreOrder::getUid,uid);
}
wrapperTwo.lambda().eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue())
.eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue())
.eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_0.getValue());
@ -1192,7 +1244,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
//订单待发货 数量
QueryWrapper<YxStoreOrder> wrapperThree = new QueryWrapper<>();
if(uid != null) wrapperThree.lambda().eq(YxStoreOrder::getUid,uid);
if(uid != null) {
wrapperThree.lambda().eq(YxStoreOrder::getUid,uid);
}
wrapperThree.lambda().eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue())
.eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue())
.eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_0.getValue());
@ -1200,7 +1254,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
//订单待收货 数量
QueryWrapper<YxStoreOrder> wrapperFour = new QueryWrapper<>();
if(uid != null) wrapperFour.lambda().eq(YxStoreOrder::getUid,uid);
if(uid != null) {
wrapperFour.lambda().eq(YxStoreOrder::getUid,uid);
}
wrapperFour.lambda().eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue())
.eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue())
.eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_1.getValue());
@ -1208,7 +1264,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
//订单待评价 数量
QueryWrapper<YxStoreOrder> wrapperFive = new QueryWrapper<>();
if(uid != null) wrapperFive.lambda().eq(YxStoreOrder::getUid,uid);
if(uid != null) {
wrapperFive.lambda().eq(YxStoreOrder::getUid,uid);
}
wrapperFive.lambda().eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue())
.eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue())
.eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_2.getValue());
@ -1216,7 +1274,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
//订单已完成 数量
QueryWrapper<YxStoreOrder> wrapperSix= new QueryWrapper<>();
if(uid != null) wrapperSix.lambda().eq(YxStoreOrder::getUid,uid);
if(uid != null) {
wrapperSix.lambda().eq(YxStoreOrder::getUid,uid);
}
wrapperSix.lambda().eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue())
.eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue())
.eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_3.getValue());
@ -1224,7 +1284,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
//订单退款
QueryWrapper<YxStoreOrder> wrapperSeven= new QueryWrapper<>();
if(uid != null) wrapperSeven.lambda().eq(YxStoreOrder::getUid,uid);
if(uid != null) {
wrapperSeven.lambda().eq(YxStoreOrder::getUid,uid);
}
String[] strArr = {"1","2"};
wrapperSeven.lambda().eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue())
.in(YxStoreOrder::getRefundStatus,Arrays.asList(strArr));
@ -1364,7 +1426,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
orderStatusService.create(orderInfo.getId(),OrderLogEnum.PAY_ORDER_SUCCESS.getValue(),
OrderLogEnum.PAY_ORDER_SUCCESS.getDesc());
//拼团
if(orderInfo.getCombinationId() > 0) pinkService.createPink(orderInfo);
if(orderInfo.getCombinationId() > 0) {
pinkService.createPink(orderInfo);
}
//砍价
if(orderInfo.getBargainId() > 0) {
@ -1374,7 +1438,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
YxUser userInfo = userService.getById(orderInfo.getUid());
//增加流水
String payTypeMsg = PayTypeEnum.WEIXIN.getDesc();
if(PayTypeEnum.YUE.getValue().equals(payType)) payTypeMsg = PayTypeEnum.YUE.getDesc();
if(PayTypeEnum.YUE.getValue().equals(payType)) {
payTypeMsg = PayTypeEnum.YUE.getDesc();
}
billService.expend(userInfo.getUid(), "购买商品",
BillDetailEnum.CATEGORY_1.getValue(),
BillDetailEnum.TYPE_3.getValue(),
@ -1403,12 +1469,20 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
@Override
public String aliPay(String orderId) throws Exception {
AlipayConfig alipay = alipayService.find();
if(ObjectUtil.isNull(alipay)) throw new YshopException("请先配置支付宝");
if(ObjectUtil.isNull(alipay)) {
throw new YshopException("请先配置支付宝");
}
YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId,null);
if(ObjectUtil.isNull(orderInfo)) throw new YshopException("订单不存在");
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())) throw new YshopException("订单已支付");
if(ObjectUtil.isNull(orderInfo)) {
throw new YshopException("订单不存在");
}
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())) {
throw new YshopException("该订单已支付");
}
if(orderInfo.getPayPrice().compareTo(BigDecimal.ZERO) <= 0) throw new YshopException("该支付无需支付");
if(orderInfo.getPayPrice().compareTo(BigDecimal.ZERO) <= 0) {
throw new YshopException("该支付无需支付");
}
TradeVo trade = new TradeVo();
trade.setOutTradeNo(orderId);
String payUrl = alipayService.toPayAsWeb(alipay,trade);
@ -1427,9 +1501,13 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
@Override
public void yuePay(String orderId, Long uid) {
YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId,uid);
if(ObjectUtil.isNull(orderInfo)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(orderInfo)) {
throw new YshopException("订单不存在");
}
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())) throw new YshopException("该订单已支付");
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())) {
throw new YshopException("该订单已支付");
}
YxUserQueryVo userInfo = userService.getYxUserById(uid);
@ -1459,7 +1537,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
wrapper.lambda().and(
i->i.eq(YxStoreOrder::getOrderId,unique).or().eq(YxStoreOrder::getUnique,unique).or()
.eq(YxStoreOrder::getExtendOrderId,unique));
if(uid != null) wrapper.lambda().eq(YxStoreOrder::getUid,uid);
if(uid != null) {
wrapper.lambda().eq(YxStoreOrder::getUid,uid);
}
return generator.convert(yxStoreOrderMapper.selectOne(wrapper),YxStoreOrderQueryVo.class);
}
@ -1506,7 +1586,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
storeBargainService.decStockIncSales(storeCartVO.getCartNum(),bargainId);
} else {
productService.decProductStock(storeCartVO.getCartNum(),storeCartVO.getProductId(),
storeCartVO.getProductAttrUnique(),0l,"");
storeCartVO.getProductAttrUnique(), 0L,"");
}
}
}
@ -1533,7 +1613,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
private BigDecimal getGainIntegral(List<YxStoreCartQueryVo> cartInfo){
BigDecimal gainIntegral = BigDecimal.ZERO;
for (YxStoreCartQueryVo cart : cartInfo) {
if(cart.getCombinationId() >0 || cart.getSeckillId() > 0 || cart.getBargainId() > 0) continue;
if(cart.getCombinationId() >0 || cart.getSeckillId() > 0 || cart.getBargainId() > 0) {
continue;
}
BigDecimal cartInfoGainIntegral = BigDecimal.ZERO;
Double gain = cart.getProductInfo().getGiveIntegral().doubleValue();
if(gain > 0){
@ -1614,7 +1696,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
return;
}
if(order.getUseIntegral().compareTo(BigDecimal.ZERO) <= 0) return;
if(order.getUseIntegral().compareTo(BigDecimal.ZERO) <= 0) {
return;
}
if(!OrderStatusEnum.STATUS_MINUS_2.getValue().equals(order.getStatus())
&& !OrderInfoEnum.REFUND_STATUS_2.getValue().equals(order.getRefundStatus())
@ -1651,7 +1735,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
*/
private CacheDto getCacheOrderInfo(Long uid, String key) {
Object obj = redisUtils.get(ShopConstants.YSHOP_ORDER_CACHE_KEY + uid + key);
if(obj == null) return null;
if(obj == null) {
return null;
}
return JSON.parseObject(obj.toString(), CacheDto.class);
}
@ -1733,7 +1819,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
private BigDecimal handlePostage(List<YxStoreCartQueryVo> cartInfo,YxUserAddress userAddress){
BigDecimal storePostage = BigDecimal.ZERO;
if(userAddress != null){
if(userAddress.getCityId() == null) return storePostage;
if(userAddress.getCityId() == null) {
return storePostage;
}
//城市包括默认
int cityId = userAddress.getCityId();
List<Integer> citys = new ArrayList<>();
@ -1782,7 +1870,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
Integer tempId = storeCartVO.getProductInfo().getTempId();
//处理拼团等营销商品没有设置运费模板
if(tempId == null) return storePostage;
if(tempId == null) {
return storePostage;
}
//根据模板类型获取相应的数量
double num = 0d;
@ -1832,7 +1922,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
.le(YxShippingTemplatesFree::getNumber,mapValue.getNumber())
.le(YxShippingTemplatesFree::getPrice,mapValue.getPrice()));
//满足包邮条件剔除
if(count > 0) templateDTOMap.remove(mapKey);
if(count > 0) {
templateDTOMap.remove(mapKey);
}
}
//处理区域邮费
@ -1892,16 +1984,16 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
private BigDecimal getOrderSumPrice(List<YxStoreCartQueryVo> cartInfo, String key) {
BigDecimal sumPrice = BigDecimal.ZERO;
if(key.equals("truePrice")){
if("truePrice".equals(key)){
for (YxStoreCartQueryVo storeCart : cartInfo) {
sumPrice = NumberUtil.add(sumPrice,NumberUtil.mul(storeCart.getCartNum(),storeCart.getTruePrice()));
}
}else if(key.equals("costPrice")){
}else if("costPrice".equals(key)){
for (YxStoreCartQueryVo storeCart : cartInfo) {
sumPrice = NumberUtil.add(sumPrice,
NumberUtil.mul(storeCart.getCartNum(),storeCart.getCostPrice()));
}
}else if(key.equals("vipTruePrice")){
}else if("vipTruePrice".equals(key)){
for (YxStoreCartQueryVo storeCart : cartInfo) {
sumPrice = NumberUtil.add(sumPrice,
NumberUtil.mul(storeCart.getCartNum(),storeCart.getVipTruePrice()));
@ -2195,7 +2287,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
str = "[砍价订单]";
}
if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(shippingType)) str = "[核销订单]";
if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(shippingType)) {
str = "[核销订单]";
}
return str;
}

View File

@ -143,7 +143,9 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
* @param productId 商品id
*/
private void clearProductAttr(Long productId) {
if(ObjectUtil.isNull(productId)) throw new YshopException("产品不存在");
if(ObjectUtil.isNull(productId)) {
throw new YshopException("产品不存在");
}
yxStoreProductAttrMapper.delete(Wrappers.<YxStoreProductAttr>lambdaQuery()
.eq(YxStoreProductAttr::getProductId,productId));
@ -180,7 +182,9 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
}else {
res = yxStoreProductAttrValueMapper.decStockIncSales(num,productId,unique);
}
if(res == 0) throw new YshopException("商品库存不足");
if(res == 0) {
throw new YshopException("商品库存不足");
}
}

View File

@ -62,7 +62,9 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStorePr
*/
@Override
public void addRroductRelation(long productId,long uid) {
if(isProductRelation(productId,uid)) throw new YshopException("已收藏");
if(isProductRelation(productId,uid)) {
throw new YshopException("已收藏");
}
YxStoreProductRelation storeProductRelation = YxStoreProductRelation.builder()
.productId(productId)
.uid(uid)
@ -81,7 +83,9 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStorePr
.eq(YxStoreProductRelation::getProductId,productId)
.eq(YxStoreProductRelation::getUid,uid)
.one();
if(productRelation == null) throw new YshopException("已取消");
if(productRelation == null) {
throw new YshopException("已取消");
}
this.removeById(productRelation.getId());
@ -100,7 +104,9 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStorePr
.selectCount(Wrappers.<YxStoreProductRelation>lambdaQuery()
.eq(YxStoreProductRelation::getUid,uid)
.eq(YxStoreProductRelation::getProductId,productId));
if(count > 0) return true;
if(count > 0) {
return true;
}
return false;
}

View File

@ -151,7 +151,9 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
res = storeProductMapper.decStockIncSales(num,productId);
}
if(res == 0) throw new YshopException("商品库存不足");
if(res == 0) {
throw new YshopException("商品库存不足");
}
}
@ -193,7 +195,9 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
.eq(YxStoreProductAttrValue::getUnique, unique)
.eq(YxStoreProductAttrValue::getProductId, productId));
if (storeProductAttrValue == null) return 0;
if (storeProductAttrValue == null) {
return 0;
}
if("pink".equals(type)){
return storeProductAttrValue.getPinkStock();
}else if ("seckill".equals(type)){
@ -482,7 +486,9 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
//添加商品
YxStoreProduct yxStoreProduct = new YxStoreProduct();
BeanUtil.copyProperties(storeProductDto,yxStoreProduct,"sliderImage");
if(storeProductDto.getSliderImage().isEmpty()) throw new YshopException("请上传轮播图");
if(storeProductDto.getSliderImage().isEmpty()) {
throw new YshopException("请上传轮播图");
}
yxStoreProduct.setPrice(BigDecimal.valueOf(resultDTO.getMinPrice()));
yxStoreProduct.setOtPrice(BigDecimal.valueOf(resultDTO.getMinOtPrice()));
@ -683,7 +689,9 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
.reduce(Integer::sum)
.orElse(0);
if(stock <= 0) throw new YshopException("库存不能低于0");
if(stock <= 0) {
throw new YshopException("库存不能低于0");
}
return ProductResultDto.builder()
.minPrice(minPrice)
@ -807,14 +815,20 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
fromatDetailDTOList.stream()
.map(FromatDetailDto::getDetail)
.forEach(i -> {
if(i == null || i.isEmpty()) throw new YshopException("请至少添加一个规格值哦");
if(i == null || i.isEmpty()) {
throw new YshopException("请至少添加一个规格值哦");
}
String str = ArrayUtil.join(i.toArray(),",");
if(str.contains("-")) throw new YshopException("规格值里包含'-',请重新添加");
if(str.contains("-")) {
throw new YshopException("规格值里包含'-',请重新添加");
}
});
if(fromatDetailDTOList.size() > 1){
for (int i=0; i < fromatDetailDTOList.size() - 1;i++){
if(i == 0) data = fromatDetailDTOList.get(i).getDetail();
if(i == 0) {
data = fromatDetailDTOList.get(i).getDetail();
}
List<String> tmp = new LinkedList<>();
for (String v : data) {
for (String g : fromatDetailDTOList.get(i+1).getDetail()) {

View File

@ -55,12 +55,16 @@ public class YxSystemConfigServiceImpl extends BaseServiceImpl<SystemConfigMappe
@Override
public String getData(String name) {
String result = redisUtils.getY(name);
if(StrUtil.isNotBlank(result)) return result;
if(StrUtil.isNotBlank(result)) {
return result;
}
QueryWrapper<YxSystemConfig> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(YxSystemConfig::getMenuName,name);
YxSystemConfig systemConfig = this.baseMapper.selectOne(wrapper);
if(systemConfig == null) return "";
if(systemConfig == null) {
return "";
}
return systemConfig.getValue();
}

View File

@ -94,9 +94,13 @@ public class YxSystemStoreServiceImpl extends BaseServiceImpl<SystemStoreMapper,
.eq(YxSystemStore::getIsShow, ShopCommonEnum.SHOW_1.getValue())
.orderByDesc(YxSystemStore::getId)
.last("limit 1"));
if(yxSystemStore == null) return null;
if(yxSystemStore == null) {
return null;
}
String mention = RedisUtil.get(ShopKeyUtils.getStoreSelfMention());
if(StrUtil.isBlank(mention) || ShopCommonEnum.ENABLE_2.getValue().toString().equals(mention)) return null;
if(StrUtil.isBlank(mention) || ShopCommonEnum.ENABLE_2.getValue().toString().equals(mention)) {
return null;
}
YxSystemStoreQueryVo systemStoreQueryVo = generator.convert(yxSystemStore,YxSystemStoreQueryVo.class);
if(StrUtil.isNotEmpty(latitude) && StrUtil.isNotEmpty(longitude)){
double distance = LocationUtils.getDistance(Double.valueOf(latitude),Double.valueOf(longitude),

View File

@ -58,7 +58,9 @@ public class YxSystemStoreStaffServiceImpl extends BaseServiceImpl<SystemStoreSt
YxSystemStoreStaff storeStaff = new YxSystemStoreStaff();
storeStaff.setUid(uid);
storeStaff.setVerifyStatus(ShopCommonEnum.IS_STATUS_1.getValue());
if(storeId != null) storeStaff.setStoreId(storeId);
if(storeId != null) {
storeStaff.setStoreId(storeId);
}
return this.baseMapper.selectCount(Wrappers.query(storeStaff)) > 0;
}

View File

@ -179,7 +179,9 @@ public class YxShippingTemplatesServiceImpl extends BaseServiceImpl<YxShippingTe
}
if(shippingTemplatesFrees.isEmpty()) throw new YshopException("请添加包邮区域");
if(shippingTemplatesFrees.isEmpty()) {
throw new YshopException("请添加包邮区域");
}
yxShippingTemplatesFreeService.saveBatch(shippingTemplatesFrees);
@ -243,7 +245,9 @@ public class YxShippingTemplatesServiceImpl extends BaseServiceImpl<YxShippingTe
}
}
if(shippingTemplatesRegions.isEmpty()) throw new BusinessException("请添加区域");
if(shippingTemplatesRegions.isEmpty()) {
throw new BusinessException("请添加区域");
}
yxShippingTemplatesRegionService.saveBatch(shippingTemplatesRegions);

View File

@ -74,7 +74,9 @@ public class YxSystemUserLevelServiceImpl extends BaseServiceImpl<SystemUserLeve
int grade = 0;
for (YxSystemUserLevel userLevel : list) {
if(userLevel.getId() == levelId) grade = userLevel.getGrade();
if(userLevel.getId() == levelId) {
grade = userLevel.getGrade();
}
}
YxSystemUserLevel userLevel = this.lambdaQuery()
@ -83,7 +85,9 @@ public class YxSystemUserLevelServiceImpl extends BaseServiceImpl<SystemUserLeve
.gt(YxSystemUserLevel::getGrade,grade)
.last("limit 1")
.one();
if(ObjectUtil.isNull(userLevel)) return 0;
if(ObjectUtil.isNull(userLevel)) {
return 0;
}
return userLevel.getId();
}
@ -113,7 +117,9 @@ public class YxSystemUserLevelServiceImpl extends BaseServiceImpl<SystemUserLeve
//会员等级列表
List<YxSystemUserLevelQueryVo> list = this.getLevelListAndGrade(levelId);
if(list.isEmpty()) throw new YshopException("请后台设置会员等级");
if(list.isEmpty()) {
throw new YshopException("请后台设置会员等级");
}
//任务列表
TaskDto taskDTO = systemUserTaskService.getTaskList(list.get(0).getId(),uid);
@ -138,7 +144,9 @@ public class YxSystemUserLevelServiceImpl extends BaseServiceImpl<SystemUserLeve
.list();
List<YxSystemUserLevelQueryVo> newList = generator.convert(list,YxSystemUserLevelQueryVo.class);
for (YxSystemUserLevelQueryVo userLevelQueryVo : newList) {
if(userLevelQueryVo.getId().compareTo(levelId) == 0) grade = userLevelQueryVo.getGrade();
if(userLevelQueryVo.getId().compareTo(levelId) == 0) {
grade = userLevelQueryVo.getGrade();
}
if(grade.compareTo(userLevelQueryVo.getGrade()) < 0){
userLevelQueryVo.setIsClear(true); //不解锁
}else{

View File

@ -94,7 +94,9 @@ public class YxSystemUserTaskServiceImpl extends BaseServiceImpl<SystemUserTaskM
.list();
List<Integer> taskIds = list.stream().map(YxSystemUserTask::getId)
.collect(Collectors.toList());
if(taskIds.isEmpty()) return 0;
if(taskIds.isEmpty()) {
return 0;
}
int count = yxUserTaskFinishMapper.selectCount(Wrappers.<YxUserTaskFinish>lambdaQuery()
.in(YxUserTaskFinish::getTaskId,taskIds)
@ -192,7 +194,9 @@ public class YxSystemUserTaskServiceImpl extends BaseServiceImpl<SystemUserTaskM
List<YxSystemUserTaskDto> systemUserTaskDTOS = generator.convert(page.getList(),YxSystemUserTaskDto.class);
for (YxSystemUserTaskDto systemUserTaskDTO : systemUserTaskDTOS) {
YxSystemUserLevel userLevel=systemUserLevelService.getById(systemUserTaskDTO.getLevelId());
if(userLevel == null) continue;
if(userLevel == null) {
continue;
}
systemUserTaskDTO.setLevalName(userLevel.getName());
}
Map<String, Object> map = new LinkedHashMap<>(2);

View File

@ -72,6 +72,7 @@ public class YxUserAddressServiceImpl extends BaseServiceImpl<YxUserAddressMappe
* @param uid uid
* @param param AddressParam
*/
@Override
public Long addAndEdit(Long uid, AddressParam param){
YxUserAddress userAddress = YxUserAddress.builder()
.city(param.getAddress().getCity())

View File

@ -68,7 +68,9 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
levelId = yxUserLevel.getLevelId();
}
int nextLevelId = systemUserLevelService.getNextLevelId(levelId);
if(nextLevelId == 0) return false;
if(nextLevelId == 0) {
return false;
}
int finishCount = systemUserTaskService.getTaskComplete(nextLevelId,uid);
@ -95,10 +97,16 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
.eq(YxUserLevel::getStatus, ShopCommonEnum.IS_STATUS_1.getValue())
.eq(YxUserLevel::getUid,uid)
.orderByDesc(YxUserLevel::getGrade);
if(grade != null) wrapper.lambda().lt(YxUserLevel::getGrade,grade);
if(grade != null) {
wrapper.lambda().lt(YxUserLevel::getGrade,grade);
}
YxUserLevel userLevel = this.getOne(wrapper,false);
if(ObjectUtil.isNull(userLevel)) return null;
if(ShopCommonEnum.IS_FOREVER_1.getValue().equals(userLevel.getIsForever())) return userLevel;
if(ObjectUtil.isNull(userLevel)) {
return null;
}
if(ShopCommonEnum.IS_FOREVER_1.getValue().equals(userLevel.getIsForever())) {
return userLevel;
}
int nowTime = OrderUtil.getSecondTimestampTwo();
if(nowTime > userLevel.getValidTime()){
if(ShopCommonEnum.IS_STATUS_1.getValue().equals(userLevel.getStatus())){
@ -119,7 +127,9 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
private void setUserLevel(Long uid, int levelId){
YxSystemUserLevel systemUserLevelQueryVo = systemUserLevelService
.getById(levelId);
if(ObjectUtil.isNull(systemUserLevelQueryVo)) return;
if(ObjectUtil.isNull(systemUserLevelQueryVo)) {
return;
}
int validTime = systemUserLevelQueryVo.getValidDate() * 86400;

View File

@ -167,9 +167,13 @@ public class YxUserServiceImpl extends BaseServiceImpl<UserMapper, YxUser> imple
.collect(Collectors.toList());
List<PromUserDto> list = new ArrayList<>();
if (userIds.isEmpty()) return list;
if (userIds.isEmpty()) {
return list;
}
if (StrUtil.isBlank(sort)) sort = "u.uid desc";
if (StrUtil.isBlank(sort)) {
sort = "u.uid desc";
}
Page<YxUser> pageModel = new Page<>(page, limit);
if (ShopCommonEnum.GRADE_0.getValue().equals(grade)) {//-级
@ -181,7 +185,9 @@ public class YxUserServiceImpl extends BaseServiceImpl<UserMapper, YxUser> imple
List<Long> userIdsT = userListT.stream()
.map(YxUser::getUid)
.collect(Collectors.toList());
if (userIdsT.isEmpty()) return list;
if (userIdsT.isEmpty()) {
return list;
}
list = yxUserMapper.getUserSpreadCountList(pageModel, userIdsT,
keyword, sort);
@ -224,14 +230,18 @@ public class YxUserServiceImpl extends BaseServiceImpl<UserMapper, YxUser> imple
public void backOrderBrokerage(YxStoreOrderQueryVo order) {
//如果分销没开启直接返回
String open = systemConfigService.getData(SystemConfigConstants.STORE_BROKERAGE_OPEN);
if(StrUtil.isBlank(open) || ShopCommonEnum.ENABLE_2.getValue().toString().equals(open)) return;
if(StrUtil.isBlank(open) || ShopCommonEnum.ENABLE_2.getValue().toString().equals(open)) {
return;
}
//获取购买商品的用户
YxUser userInfo = this.getById(order.getUid());
System.out.println("userInfo:"+userInfo);
//当前用户不存在 没有上级 直接返回
if(ObjectUtil.isNull(userInfo) || userInfo.getSpreadUid() == 0) return;
if(ObjectUtil.isNull(userInfo) || userInfo.getSpreadUid() == 0) {
return;
}
YxUser preUser = this.getById(userInfo.getSpreadUid());
@ -241,7 +251,9 @@ public class YxUserServiceImpl extends BaseServiceImpl<UserMapper, YxUser> imple
//返佣金额小于等于0 直接返回不返佣金
if(brokeragePrice.compareTo(BigDecimal.ZERO) <= 0) return;
if(brokeragePrice.compareTo(BigDecimal.ZERO) <= 0) {
return;
}
//计算上级推广员返佣之后的金额
double balance = NumberUtil.add(preUser.getBrokeragePrice(),brokeragePrice).doubleValue();
@ -351,9 +363,13 @@ public class YxUserServiceImpl extends BaseServiceImpl<UserMapper, YxUser> imple
.last("limit 1");
YxUserLevel userLevel = userLevelService.getOne(wrapper);
YxSystemUserLevel systemUserLevel = new YxSystemUserLevel();
if(ObjectUtil.isNotNull(userLevel)) systemUserLevel= systemUserLevelService.getById(userLevel.getLevelId());
if(ObjectUtil.isNotNull(userLevel)) {
systemUserLevel= systemUserLevelService.getById(userLevel.getLevelId());
}
int discount = 100;
if(ObjectUtil.isNotNull(userLevel)) discount = systemUserLevel.getDiscount().intValue();
if(ObjectUtil.isNotNull(userLevel)) {
discount = systemUserLevel.getDiscount().intValue();
}
return NumberUtil.mul(NumberUtil.div(discount,100),price);
}
@ -365,27 +381,43 @@ public class YxUserServiceImpl extends BaseServiceImpl<UserMapper, YxUser> imple
*/
@Override
public void setSpread(String spread, long uid) {
if(StrUtil.isBlank(spread) || !NumberUtil.isNumber(spread)) return;
if(StrUtil.isBlank(spread) || !NumberUtil.isNumber(spread)) {
return;
}
//如果分销没开启直接返回
String open = systemConfigService.getData(SystemConfigConstants.STORE_BROKERAGE_OPEN);
if(StrUtil.isBlank(open) || ShopCommonEnum.ENABLE_2.getValue().toString().equals(open)) return;
if(StrUtil.isBlank(open) || ShopCommonEnum.ENABLE_2.getValue().toString().equals(open)) {
return;
}
//当前用户信息
YxUser userInfo = this.getById(uid);
if(ObjectUtil.isNull(userInfo)) return;
if(ObjectUtil.isNull(userInfo)) {
return;
}
//当前用户有上级直接返回
if(userInfo.getSpreadUid() != null && userInfo.getSpreadUid() > 0) return;
if(userInfo.getSpreadUid() != null && userInfo.getSpreadUid() > 0) {
return;
}
//没有推广编号直接返回
long spreadInt = Long.valueOf(spread);
if(spreadInt == 0) return;
if(spreadInt == uid) return;
if(spreadInt == 0) {
return;
}
if(spreadInt == uid) {
return;
}
//不能互相成为上下级
YxUser userInfoT = this.getById(spreadInt);
if(ObjectUtil.isNull(userInfoT)) return;
if(ObjectUtil.isNull(userInfoT)) {
return;
}
if(userInfoT.getSpreadUid() == uid) return;
if(userInfoT.getSpreadUid() == uid) {
return;
}
YxUser yxUser = YxUser.builder()
.spreadUid(spreadInt)
@ -410,7 +442,9 @@ public class YxUserServiceImpl extends BaseServiceImpl<UserMapper, YxUser> imple
YxUser userInfoTwo = this.getById(userInfo.getSpreadUid());
//上推广人不存在 或者 上推广人没有上级 直接返回
if(ObjectUtil.isNull(userInfoTwo) || userInfoTwo.getSpreadUid() == 0) return;
if(ObjectUtil.isNull(userInfoTwo) || userInfoTwo.getSpreadUid() == 0) {
return;
}
//指定分销 判断 上上级是否时推广员 如果不是推广员直接返回
@ -421,7 +455,9 @@ public class YxUserServiceImpl extends BaseServiceImpl<UserMapper, YxUser> imple
BigDecimal brokeragePrice = this.computeProductBrokerage(order,Brokerage.LEVEL_2);
//返佣金额小于等于0 直接返回不返佣金
if(brokeragePrice.compareTo(BigDecimal.ZERO) <= 0) return;
if(brokeragePrice.compareTo(BigDecimal.ZERO) <= 0) {
return;
}
//获取上上级推广员信息
double balance = NumberUtil.add(preUser.getBrokeragePrice(),brokeragePrice).doubleValue();
@ -627,7 +663,9 @@ public class YxUserServiceImpl extends BaseServiceImpl<UserMapper, YxUser> imple
}else{
mark = "系统扣除了"+param.getMoney()+"余额";
newMoney = NumberUtil.sub(yxUser.getNowMoney(),param.getMoney()).doubleValue();
if(newMoney < 0) newMoney = 0d;
if(newMoney < 0) {
newMoney = 0d;
}
billService.expend(yxUser.getUid(), "系统减少余额",
BillDetailEnum.CATEGORY_1.getValue(),
BillDetailEnum.TYPE_7.getValue(),

View File

@ -79,10 +79,14 @@ public class YxUserSignServiceImpl extends BaseServiceImpl<YxUserSignMapper, YxU
@Override
public int sign(YxUser yxUser) {
List<JSONObject> list = systemGroupDataService.getDatas(ShopConstants.YSHOP_SIGN_DAY_NUM);
if(ObjectUtil.isNull(list) || list.isEmpty()) throw new YshopException("请先配置签到天数");
if(ObjectUtil.isNull(list) || list.isEmpty()) {
throw new YshopException("请先配置签到天数");
}
boolean isDaySign = this.getToDayIsSign(yxUser.getUid());
if(isDaySign) throw new YshopException("已签到");
if(isDaySign) {
throw new YshopException("已签到");
}
int signNumber = 0; //积分
int userSignNum = yxUser.getSignNum(); //签到次数
if(getYesterDayIsSign(yxUser.getUid())){
@ -121,7 +125,9 @@ public class YxUserSignServiceImpl extends BaseServiceImpl<YxUserSignMapper, YxU
.signNum(userSignNum)
.build();
boolean res = yxUserService.updateById(user);
if(!res) throw new YshopException("签到失败");
if(!res) {
throw new YshopException("签到失败");
}
//插入流水
billService.income(yxUser.getUid(),title, BillDetailEnum.CATEGORY_2.getValue(),
@ -162,7 +168,9 @@ public class YxUserSignServiceImpl extends BaseServiceImpl<YxUserSignMapper, YxU
userQueryVo.setSumSignDay(sumSignDay);
userQueryVo.setIsDaySign(isDaySign);
userQueryVo.setIsYesterDaySign(isYesterDaySign);
if(!isDaySign && !isYesterDaySign) userQueryVo.setSignNum(0);
if(!isDaySign && !isYesterDaySign) {
userQueryVo.setSignNum(0);
}
return userQueryVo;
}
@ -176,7 +184,9 @@ public class YxUserSignServiceImpl extends BaseServiceImpl<YxUserSignMapper, YxU
int count = this.lambdaQuery().eq(YxUserSign::getUid,uid)
.ge(YxUserSign::getCreateTime,today)
.count();
if(count > 0) return true;
if(count > 0) {
return true;
}
return false;
}
@ -193,7 +203,9 @@ public class YxUserSignServiceImpl extends BaseServiceImpl<YxUserSignMapper, YxU
.lt(YxUserSign::getCreateTime,today)
.ge(YxUserSign::getCreateTime,yesterday)
.count();
if(count > 0) return true;
if(count > 0) {
return true;
}
return false;
}

View File

@ -59,7 +59,7 @@ public class MetaHandler implements MetaObjectHandler {
this.setFieldValByName("delFlag", false, metaObject);
}
if(metaObject.hasSetter("addTime")){
String timestamp = String.valueOf(new Date().getTime()/1000);
String timestamp = String.valueOf(System.currentTimeMillis()/1000);
this.setFieldValByName("addTime", Integer.valueOf(timestamp), metaObject);
}
} catch (Exception e) {

View File

@ -90,7 +90,9 @@ public class StoreCategoryController {
}
boolean checkResult = yxStoreCategoryService.checkCategory(resources.getPid());
if(!checkResult) throw new YshopException("分类最多能添加2级哦");
if(!checkResult) {
throw new YshopException("分类最多能添加2级哦");
}
return new ResponseEntity<>(yxStoreCategoryService.save(resources),HttpStatus.CREATED);
}
@ -112,7 +114,9 @@ public class StoreCategoryController {
boolean checkResult = yxStoreCategoryService.checkCategory(resources.getPid());
if(!checkResult) throw new YshopException("分类最多能添加2级哦");
if(!checkResult) {
throw new YshopException("分类最多能添加2级哦");
}
yxStoreCategoryService.saveOrUpdate(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
@ -142,12 +146,16 @@ public class StoreCategoryController {
int count = yxStoreCategoryService.lambdaQuery()
.eq(YxStoreCategory::getPid,id)
.count();
if(count > 0) throw new YshopException("请先删除子分类");
if(count > 0) {
throw new YshopException("请先删除子分类");
}
int countP = yxStoreProductService.lambdaQuery()
.eq(YxStoreProduct::getCateId,id)
.count();
if(countP > 0) throw new YshopException("当前分类下有商品不可删除");
if(countP > 0) {
throw new YshopException("当前分类下有商品不可删除");
}
}
}

View File

@ -131,8 +131,12 @@ public class StoreOrderController {
@PutMapping(value = "/yxStoreOrder")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxStoreOrder resources) {
if (StrUtil.isBlank(resources.getDeliveryName())) throw new BadRequestException("请选择快递公司");
if (StrUtil.isBlank(resources.getDeliveryId())) throw new BadRequestException("快递单号不能为空");
if (StrUtil.isBlank(resources.getDeliveryName())) {
throw new BadRequestException("请选择快递公司");
}
if (StrUtil.isBlank(resources.getDeliveryId())) {
throw new BadRequestException("快递单号不能为空");
}
yxStoreOrderService.orderDelivery(resources.getOrderId(),resources.getDeliveryId(),
resources.getDeliveryName(),resources.getDeliveryType());
@ -143,7 +147,9 @@ public class StoreOrderController {
@PutMapping(value = "/yxStoreOrder/check")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity check(@Validated @RequestBody YxStoreOrder resources) {
if (StrUtil.isBlank(resources.getVerifyCode())) throw new BadRequestException("核销码不能为空");
if (StrUtil.isBlank(resources.getVerifyCode())) {
throw new BadRequestException("核销码不能为空");
}
YxStoreOrderDto storeOrderDTO = generator.convert(yxStoreOrderService.getById(resources.getId()),YxStoreOrderDto.class);
if(!resources.getVerifyCode().equals(storeOrderDTO.getVerifyCode())){
throw new BadRequestException("核销码不对");
@ -185,8 +191,12 @@ public class StoreOrderController {
@PostMapping(value = "/yxStoreOrder/edit")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity editOrder(@RequestBody YxStoreOrder resources) {
if (ObjectUtil.isNull(resources.getPayPrice())) throw new BadRequestException("请输入支付金额");
if (resources.getPayPrice().doubleValue() < 0) throw new BadRequestException("金额不能低于0");
if (ObjectUtil.isNull(resources.getPayPrice())) {
throw new BadRequestException("请输入支付金额");
}
if (resources.getPayPrice().doubleValue() < 0) {
throw new BadRequestException("金额不能低于0");
}
YxStoreOrderDto storeOrder = generator.convert(yxStoreOrderService.getById(resources.getId()),YxStoreOrderDto.class);
//判断金额是否有变动,生成一个额外订单号去支付
int res = NumberUtil.compare(storeOrder.getPayPrice().doubleValue(), resources.getPayPrice().doubleValue());
@ -208,7 +218,9 @@ public class StoreOrderController {
@PostMapping(value = "/yxStoreOrder/remark")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity editOrderRemark(@RequestBody YxStoreOrder resources) {
if (StrUtil.isBlank(resources.getRemark())) throw new BadRequestException("请输入备注");
if (StrUtil.isBlank(resources.getRemark())) {
throw new BadRequestException("请输入备注");
}
yxStoreOrderService.saveOrUpdate(resources);
return new ResponseEntity(HttpStatus.OK);
}
@ -223,7 +235,9 @@ public class StoreOrderController {
ExpressService expressService = ExpressAutoConfiguration.expressService();
ExpressInfo expressInfo = expressService.getExpressInfo(expressInfoDo.getOrderCode(),
expressInfoDo.getShipperCode(), expressInfoDo.getLogisticCode());
if(!expressInfo.isSuccess()) throw new BadRequestException(expressInfo.getReason());
if(!expressInfo.isSuccess()) {
throw new BadRequestException(expressInfo.getReason());
}
return new ResponseEntity<>(expressInfo, HttpStatus.OK);
}

View File

@ -84,7 +84,7 @@ public class WechatArticleService {
WxMpMassSendResult massResult = wxMpService.getMassMessageService()
.massGroupMessageSend(massMessage);
if(!massResult.getErrorCode().equals("0")) {
if(!"0".equals(massResult.getErrorCode())) {
log.info("error:"+massResult.getErrorMsg());
throw new ErrorRequestException("发送失败");
}

View File

@ -88,7 +88,9 @@ public class SystemStoreController {
@PreAuthorize("@el.check('yxSystemStore:getl')")
public ResponseEntity<Object> create(@Validated @RequestBody String jsonStr){
String key = RedisUtil.get(ShopKeyUtils.getTengXunMapKey());
if(StrUtil.isBlank(key)) throw new BadRequestException("请先配置腾讯地图key");
if(StrUtil.isBlank(key)) {
throw new BadRequestException("请先配置腾讯地图key");
}
JSONObject jsonObject = JSON.parseObject(jsonStr);
String addr = jsonObject.getString("addr");
String url = StrUtil.format("?address={}&key={}",addr,key);

View File

@ -97,7 +97,7 @@ public class ShippingTemplatesController {
List<YxStoreProduct> productList = yxStoreProductService.list();
Arrays.asList(ids).forEach(id->{
for (YxStoreProduct yxStoreProduct : productList) {
if(id==yxStoreProduct.getTempId()){
if(id.equals(yxStoreProduct.getTempId())){
throw new BadRequestException("运费模板存在商品关联,请删除对应商品");
}
}

View File

@ -31,8 +31,7 @@ public class WxMaConfiguration {
}
@Autowired
public WxMaConfiguration(RedisUtils redisUtils) {
this.redisUtils = redisUtils;
this.wxMaMessageHandler = wxMaMessageHandler;
WxMaConfiguration.redisUtils = redisUtils;
}
public static WxMaService getWxMaService() {
@ -67,10 +66,10 @@ public class WxMaConfiguration {
final WxMaMessageRouter router = new WxMaMessageRouter(service);
router
.rule().handler(wxMaMessageHandler).next()
.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT).event(SystemConfigConstants.BINDSTATECHANGE).handler(bindstatechangeHandler).end();
.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT).event(SystemConfigConstants.BINDSTATECHANGE).handler(BINDSTATECHANGE_HANDLER).end();
return router;
}
private static final WxMaMessageHandler bindstatechangeHandler = (wxMessage, context, service, sessionManager) -> {
private static final WxMaMessageHandler BINDSTATECHANGE_HANDLER = (wxMessage, context, service, sessionManager) -> {
wxMessage.getFromUser();
wxMessage.getContent();
return null;

View File

@ -48,9 +48,10 @@ public class ExpressService implements Serializable {
*/
public String getVendorName(String vendorCode) {
for (Map<String, String> item : properties.getVendors()) {
if (item.get("code").equals(vendorCode))
if (item.get("code").equals(vendorCode)) {
return item.get("name");
}
}
return null;
}

View File

@ -24,12 +24,14 @@ public class ExpressAutoConfiguration {
@Autowired
public ExpressAutoConfiguration(RedisUtils redisUtil) {
this.redisUtil = redisUtil;
ExpressAutoConfiguration.redisUtil = redisUtil;
}
public static ExpressService expressService() {
ExpressService expressService = (ExpressService)redisUtil.get(ShopConstants.YSHOP_EXPRESS_SERVICE);
if(expressService != null) return expressService;
if(expressService != null) {
return expressService;
}
ExpressProperties properties = new ExpressProperties();
String enable = redisUtil.getY("exp_enable");

View File

@ -26,8 +26,9 @@ public class JacksonUtil {
try {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return leaf.asText();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -42,9 +43,10 @@ public class JacksonUtil {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return mapper.convertValue(leaf, new TypeReference<List<String>>() {
});
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -57,8 +59,9 @@ public class JacksonUtil {
try {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return leaf.asInt();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -72,9 +75,10 @@ public class JacksonUtil {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return mapper.convertValue(leaf, new TypeReference<List<Integer>>() {
});
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -88,8 +92,9 @@ public class JacksonUtil {
try {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return leaf.asBoolean();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}

View File

@ -62,17 +62,17 @@ public class WxMpConfiguration {
MenuHandler menuHandler,MsgHandler msgHandler,UnsubscribeHandler unsubscribeHandler,
SubscribeHandler subscribeHandler,ScanHandler scanHandler,
RedisUtils redisUtils){
this.logHandler = logHandler;
this.nullHandler = nullHandler;
this.kfSessionHandler = kfSessionHandler;
this.storeCheckNotifyHandler = storeCheckNotifyHandler;
this.locationHandler = locationHandler;
this.menuHandler = menuHandler;
this.msgHandler = msgHandler;
this.unsubscribeHandler = unsubscribeHandler;
this.subscribeHandler = subscribeHandler;
this.scanHandler = scanHandler;
this.redisUtils = redisUtils;
WxMpConfiguration.logHandler = logHandler;
WxMpConfiguration.nullHandler = nullHandler;
WxMpConfiguration.kfSessionHandler = kfSessionHandler;
WxMpConfiguration.storeCheckNotifyHandler = storeCheckNotifyHandler;
WxMpConfiguration.locationHandler = locationHandler;
WxMpConfiguration.menuHandler = menuHandler;
WxMpConfiguration.msgHandler = msgHandler;
WxMpConfiguration.unsubscribeHandler = unsubscribeHandler;
WxMpConfiguration.subscribeHandler = subscribeHandler;
WxMpConfiguration.scanHandler = scanHandler;
WxMpConfiguration.redisUtils = redisUtils;
}

View File

@ -34,7 +34,7 @@ public class WxPayConfiguration {
@Autowired
public WxPayConfiguration(RedisUtils redisUtils) {
this.redisUtils = redisUtils;
WxPayConfiguration.redisUtils = redisUtils;
}
/**

View File

@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import cn.hutool.core.util.StrUtil;
import co.yixiang.config.SubscribeProperties;
import co.yixiang.constant.ShopConstants;
import co.yixiang.modules.user.domain.YxUser;
import co.yixiang.modules.user.service.YxUserService;
import co.yixiang.modules.user.service.dto.WechatUserDto;
@ -42,14 +43,16 @@ public class WeiXinSubscribeService {
public void rechargeSuccessNotice(String time,String price,Long uid){
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的账户金币发生变动,详情如下:");
map.put("keyword1","充值");
map.put("keyword2",time);
map.put("keyword3",price);
map.put("remark","yshop为你服务");
map.put("remark", ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.RECHARGE_SUCCESS.getValue());
this.sendSubscribeMsg( openid, tempId, "/user/account",map);
}
@ -64,7 +67,9 @@ public class WeiXinSubscribeService {
public void paySuccessNotice(String orderId,String price,Long uid){
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
Map<String,String> map = new HashMap<>();
map.put("amount1",price);
@ -87,14 +92,17 @@ public class WeiXinSubscribeService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的订单退款申请被通过,钱款将很快还至您的支付账户。");
map.put("keyword1",orderId);//订单号
//订单号
map.put("keyword1",orderId);
map.put("keyword2",price);
map.put("keyword3", time);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.REFUND_SUCCESS.getValue());
this.sendSubscribeMsg( openid,tempId, "/order/detail/"+orderId,map);
}
@ -111,14 +119,16 @@ public class WeiXinSubscribeService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isEmpty(openid)) return;
if(StrUtil.isEmpty(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","亲,宝贝已经启程了,好想快点来到你身边。");
map.put("keyword2",deliveryName);
map.put("keyword1",orderId);
map.put("keyword3",deliveryId);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.DELIVERY_SUCCESS.getValue());
this.sendSubscribeMsg( openid,tempId, "/order/detail/"+orderId,map);
}
@ -170,11 +180,17 @@ public class WeiXinSubscribeService {
*/
private String getUserOpenid(Long uid){
YxUser yxUser = userService.getById(uid);
if(yxUser == null) return "";
if(yxUser == null) {
return "";
}
WechatUserDto wechatUserDto = yxUser.getWxProfile();
if(wechatUserDto == null) return "";
if(StrUtil.isBlank(wechatUserDto.getRoutineOpenid())) return "";
if(wechatUserDto == null) {
return "";
}
if(StrUtil.isBlank(wechatUserDto.getRoutineOpenid())) {
return "";
}
return wechatUserDto.getRoutineOpenid();
}

View File

@ -72,21 +72,29 @@ public class WeixinPayService {
long uid = 0;
int payPrice = 0;
BigDecimal bigDecimal = new BigDecimal(100);
if(BillDetailEnum.TYPE_3.getValue().equals(attach)){ //普通支付
//普通支付
if(BillDetailEnum.TYPE_3.getValue().equals(attach)){
YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(orderId,null);
if(ObjectUtil.isNull(orderInfo)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(orderInfo)) {
throw new YshopException("订单不存在");
}
if(orderInfo.getPaid().equals(OrderInfoEnum.PAY_STATUS_1.getValue())) {
throw new YshopException("该订单已支付");
}
if(orderInfo.getPayPrice().compareTo(BigDecimal.ZERO) <= 0) throw new YshopException("该支付无需支付");
if(orderInfo.getPayPrice().compareTo(BigDecimal.ZERO) <= 0) {
throw new YshopException("该支付无需支付");
}
uid = orderInfo.getUid().intValue();
payPrice = bigDecimal.multiply(orderInfo.getPayPrice()).intValue();//计算分
//计算分
payPrice = bigDecimal.multiply(orderInfo.getPayPrice()).intValue();
}else{ //充值
YxUserRecharge userRecharge = userRechargeService.getOne(Wrappers.<YxUserRecharge>lambdaQuery()
.eq(YxUserRecharge::getOrderId,orderId));
if(userRecharge == null) throw new BusinessException("充值订单不存在");
if(userRecharge == null) {
throw new BusinessException("充值订单不存在");
}
if(userRecharge.getPaid().equals(OrderInfoEnum.PAY_STATUS_1.getValue())) {
throw new YshopException("该订单已支付");
@ -97,7 +105,9 @@ public class WeixinPayService {
YxUser yxUser = userService.getById(uid);
if(yxUser == null) throw new YshopException("用户错误");
if(yxUser == null) {
throw new YshopException("用户错误");
}
WechatUserDto wechatUserDto = yxUser.getWxProfile();
@ -151,15 +161,18 @@ public class WeixinPayService {
public void refundOrder(String orderId, Integer totalFee) {
YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(orderId,null);
if(PayTypeEnum.YUE.getValue().equals(orderInfo.getPayType())) return;
if(PayTypeEnum.YUE.getValue().equals(orderInfo.getPayType())) {
return;
}
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
wxPayRefundRequest.setTotalFee(totalFee);//订单总金额
//订单总金额
wxPayRefundRequest.setTotalFee(totalFee);
wxPayRefundRequest.setOutTradeNo(orderId);
wxPayRefundRequest.setOutRefundNo(orderId);
wxPayRefundRequest.setRefundFee(totalFee);//退款金额
//退款金额
wxPayRefundRequest.setRefundFee(totalFee);
wxPayRefundRequest.setNotifyUrl(this.getApiUrl() + "/api/notify/refund");
try {

View File

@ -10,6 +10,7 @@ package co.yixiang.mp.service;
import cn.hutool.core.util.StrUtil;
import co.yixiang.api.YshopException;
import co.yixiang.constant.ShopConstants;
import co.yixiang.modules.user.domain.YxUser;
import co.yixiang.modules.user.service.YxUserService;
import co.yixiang.modules.user.service.dto.WechatUserDto;
@ -57,14 +58,16 @@ public class WeixinTemplateService {
public void rechargeSuccessNotice(String time,String price,Long uid){
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的账户金币发生变动,详情如下:");
map.put("keyword1","充值");
map.put("keyword2",time);
map.put("keyword3",price);
map.put("remark","yshop为你服务");
map.put("remark", ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.RECHARGE_SUCCESS.getValue());
this.sendWxMpTemplateMessage( openid, tempId, this.getSiteUrl()+"/user/account",map);
}
@ -80,13 +83,16 @@ public class WeixinTemplateService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的订单已支付成功,我们会尽快为您发货。");
map.put("keyword1",orderId);//订单号
//订单号
map.put("keyword1",orderId);
map.put("keyword2",price);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.PAY_SUCCESS.getValue());
this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
}
@ -102,14 +108,17 @@ public class WeixinTemplateService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isBlank(openid)) return;
if(StrUtil.isBlank(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","您的订单退款申请被通过,钱款将很快还至您的支付账户。");
map.put("keyword1",orderId);//订单号
//订单号
map.put("keyword1",orderId);
map.put("keyword2",price);
map.put("keyword3", time);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.REFUND_SUCCESS.getValue());
this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
}
@ -126,14 +135,16 @@ public class WeixinTemplateService {
String openid = this.getUserOpenid(uid);
if(StrUtil.isEmpty(openid)) return;
if(StrUtil.isEmpty(openid)) {
return;
}
Map<String,String> map = new HashMap<>();
map.put("first","亲,宝贝已经启程了,好想快点来到你身边。");
map.put("keyword2",deliveryName);
map.put("keyword1",orderId);
map.put("keyword3",deliveryId);
map.put("remark","yshop为你服务");
map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
String tempId = this.getTempId(WechatTempateEnum.DELIVERY_SUCCESS.getValue());
this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
}
@ -173,7 +184,9 @@ public class WeixinTemplateService {
YxWechatTemplate yxWechatTemplate = yxWechatTemplateService.lambdaQuery()
.eq(YxWechatTemplate::getTempkey,key)
.one();
if (yxWechatTemplate == null) throw new YshopException("请后台配置key:" + key + "模板消息id");
if (yxWechatTemplate == null) {
throw new YshopException("请后台配置key:" + key + "模板消息id");
}
return yxWechatTemplate.getTempid();
}
@ -197,11 +210,17 @@ public class WeixinTemplateService {
*/
private String getUserOpenid(Long uid){
YxUser yxUser = userService.getById(uid);
if(yxUser == null) return "";
if(yxUser == null) {
return "";
}
WechatUserDto wechatUserDto = yxUser.getWxProfile();
if(wechatUserDto == null) return "";
if(StrUtil.isBlank(wechatUserDto.getOpenid())) return "";
if(wechatUserDto == null) {
return "";
}
if(StrUtil.isBlank(wechatUserDto.getOpenid())) {
return "";
}
return wechatUserDto.getOpenid();
}