This commit is contained in:
hupeng
2020-09-09 17:40:51 +08:00
6 changed files with 40 additions and 14 deletions

View File

@ -306,7 +306,7 @@ public class StoreOrderController {
public ApiResult<Boolean> comment(@Valid @RequestBody ProductReplyParam param){
YxUser user = LocalUser.getUser();
storeOrderService.orderComment(user,param.getUnique(),
EmojiParser.removeAllEmojis(param.getComment()),
param.getComment(),
param.getPics(),param.getProductScore(),param.getServiceScore());
return ApiResult.ok();
}

View File

@ -215,6 +215,7 @@ public class StoreProductController {
@RequestParam(value = "",required=false) String longitude,
@RequestParam(value = "",required=false) String from) {
long uid = LocalUser.getUser().getUid();
storeProductService.incBrowseNum(id);
ProductVo productDTO = storeProductService.goodsDetail(id,uid,latitude,longitude);
return ApiResult.ok(productDTO);
}

View File

@ -108,11 +108,10 @@ public class AuthService {
//过滤掉表情
String nickname = EmojiParser.removeAllEmojis(wxMpUser.getNickName());
String ip = IpUtil.getRequestIp();
YxUser user = YxUser.builder()
.username(openid)
.nickname(nickname)
.nickname(wxMpUser.getNickName())
.avatar(wxMpUser.getAvatarUrl())
.addIp(ip)
.lastIp(ip)
@ -121,7 +120,7 @@ public class AuthService {
//构建微信用户
WechatUserDto wechatUserDTO = WechatUserDto.builder()
.nickname(nickname)
.nickname(wxMpUser.getNickName())
.routineOpenid(wxMpUser.getOpenId())
.unionId(wxMpUser.getUnionId())
.sex(Integer.valueOf(wxMpUser.getGender()))
@ -189,7 +188,7 @@ public class AuthService {
YxUser returnUser = null;
if(yxUser == null){
//过滤掉表情
String nickname = EmojiParser.removeAllEmojis(wxMpUser.getNickname());
String nickname = wxMpUser.getNickname();
log.info("昵称:{}", nickname);
//用户保存
String ip = IpUtil.getRequestIp();

View File

@ -79,6 +79,12 @@ public interface YxStoreProductService extends BaseService<YxStoreProduct>{
*/
ProductVo goodsDetail(Long id, Long uid, String latitude, String longitude);
/**
* 商品浏览量
* @param productId
*/
void incBrowseNum(Long productId);
/**
* 商品列表
* @param page 页码

View File

@ -10,7 +10,6 @@ package co.yixiang.modules.product.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
@ -64,7 +63,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@ -148,19 +146,22 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
//先处理商品库存,活动商品也要处理,因为共享库存
int product = storeProductMapper.decStockIncSales(num,productId);
if(product == 0) {
throw new YshopException("商品库存不足");
throw new YshopException("共享商品库存不足");
}
//处理商品外层显示的库存
int res = 0;
if("combination".equals(type)){
res = storeProductMapper.decCombinationStockIncSales(num,productId,activityId);
int combinationRes = storeProductMapper.decCombinationStockIncSales(num,productId,activityId);
if(combinationRes == 0) {
throw new YshopException("拼团商品库存不足");
}
}else if("seckill".equals(type)){
res = storeProductMapper.decSeckillStockIncSales(num,productId,activityId);
int seckillRes = storeProductMapper.decSeckillStockIncSales(num,productId,activityId);
if(seckillRes == 0) {
throw new YshopException("秒杀商品库存不足");
}
}
//todo 处理砍价库存
if(res == 0) {
throw new YshopException("商品库存不足");
}
}
@ -362,6 +363,16 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
return productVo;
}
/**
* 商品浏览量
*
* @param productId
*/
@Override
public void incBrowseNum(Long productId) {
storeProductMapper.incBrowseNum(productId);
}
/**
* 商品列表

View File

@ -87,4 +87,13 @@ public interface StoreProductMapper extends CoreMapper<YxStoreProduct> {
@Update("update yx_store_seckill set stock=stock+#{num}, sales=sales-#{num}" +
" where id=#{activityId} and stock >= #{num}")
void incSeckillStockIncSales(Integer num, Long productId, Long activityId);
/**
* 商品浏览量
* @param productId
* @return
*/
@Update("update yx_store_product set browse=browse+1 " +
"where id=#{productId}")
int incBrowseNum(@Param("productId") Long productId);
}