Merge remote-tracking branch 'origin/test' into hph

# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java
This commit is contained in:
牛叉闪闪
2024-08-19 17:47:34 +08:00
38 changed files with 1452 additions and 609 deletions

View File

@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.StrUtil;
import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper;
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
import com.chaozhanggui.system.cashierservice.entity.dto.WxMsgSubDTO;
@@ -208,7 +209,6 @@ public class CommonController {
redisUtil.getIncrNum(key, "2");
}
/**
* 订阅消息
* @param wxMsgSubDTO
@@ -220,7 +220,7 @@ public class CommonController {
if (wxMsgSubDTO.getOpenId() == null || wxMsgSubDTO.getShopId() == null) {
return Result.fail("shopId或openId缺失");
}
loginService.addShopId(wxMsgSubDTO.getOpenId(), wxMsgSubDTO.getShopId(), wxMsgSubDTO.getType());
loginService.addShopId(wxMsgSubDTO.getOpenId(), wxMsgSubDTO.getShopId(), null, wxMsgSubDTO.getNickname(), wxMsgSubDTO.getAvatar());
return Result.success(CodeEnum.SUCCESS);
}
}

View File

@@ -200,11 +200,11 @@ public class LoginContoller {
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
try {
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) {
// if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) {
return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
}
log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber"));
return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString());
// }
// log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber"));
// return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString());
}
} catch (Exception e){
// e.printStackTrace();
@@ -276,6 +276,7 @@ public class LoginContoller {
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
userInfo.setId(Integer.valueOf(userId));
userInfo.setUpdatedAt(System.currentTimeMillis());
// log.info("更新用户信息 param,{}",JSONObject.toJSONString(userInfo));
return loginService.upUserInfo(userInfo);
}

View File

@@ -3,11 +3,12 @@ package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
import com.chaozhanggui.system.cashierservice.service.CartService;
import com.chaozhanggui.system.cashierservice.service.ProductService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -22,6 +23,8 @@ public class ProductController {
@Autowired
private ProductService productService;
@Autowired
private CartService cartService;
/**
* 通过桌码获取shopId
@@ -29,12 +32,15 @@ public class ProductController {
* @param code
* @return shopid
*/
@RequestMapping("queryShopIdByTableCode")
@RequestMapping("queryShop")
public Result queryShopIdByTableCode(
@RequestHeader("openId") String openId,
@RequestHeader("id") String userId,
@RequestParam("code") String code) {
return productService.queryShopIdByTableCode(userId, openId, code);
@RequestParam String lat,
@RequestParam String lng,
@RequestParam("code") String code
) {
return productService.queryShopIdByTableCode(userId, openId, code,lat,lng);
}
/**
@@ -46,24 +52,54 @@ public class ProductController {
@RequestMapping("queryProduct")
public Result queryProduct(@RequestBody Map<String, String> map) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("code")) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("shopId")) {
return Result.fail("参数错误");
}
return productService.queryProduct(
map.get("code").toString(),
map.get("shopId").toString(),
(map.containsKey("productGroupId") && ObjectUtil.isNotEmpty(map.get("productGroupId"))) ? map.get("productGroupId").toString() : "");
}
/**
* 查询规格
*
* @return
*/
@PostMapping("querySpec")
public Result querySpec(
@RequestBody QuerySpecDTO querySpecDTO
) {
if (querySpecDTO.getProductId() == null) {
return Result.fail("id不为空");
}
return Result.successWithData(productService.querySpec(querySpecDTO));
}
@GetMapping("queryProductSku")
public Result queryProductSku(
@RequestParam(value = "code", required = false) String code,
@RequestParam("shopId") String shopId,
@RequestParam("productId") String productId,
@RequestParam("spec_tag") String spec_tag
) {
return productService.queryProductSku(shopId, productId, spec_tag);
return productService.queryProductSku(code,shopId, productId, spec_tag);
}
@PostMapping("addCart")
public Result addCart(@RequestBody JSONObject jsonObject) {
log.info("添加购物车数据:{}", jsonObject);
return cartService.createCart(jsonObject);
}
@PostMapping("cleanCart")
public Result cleanCart(@RequestBody JSONObject jsonObject) {
log.info("清空购物车数据:{}", jsonObject);
cartService.clearCart(jsonObject);
return Result.success(CodeEnum.SUCCESS);
}
/**
* 团购商品详情/商品类型为 套餐商品
*/

View File

@@ -0,0 +1,40 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.TbShopAd;
import com.chaozhanggui.system.cashierservice.entity.dto.TbShopAdDto;
import com.chaozhanggui.system.cashierservice.service.TbShopAdService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* (TbShopAd)表控制层
*
* @author GYJ
* @since 2024-08-19 14:25:09
*/
@RestController
@RequestMapping("tbShopAd")
public class TbShopAdController {
private final TbShopAdService tbShopAdService;
public TbShopAdController(@Qualifier("tbShopAdServiceImpl") TbShopAdService tbShopAdService) {
this.tbShopAdService = tbShopAdService;
}
@GetMapping("/list")
public Result list(@RequestParam(value = "shopId") Integer shopId) {
List<TbShopAd> tbShopAds = tbShopAdService.shopAdList(shopId);
return Result.success(CodeEnum.ENCRYPT, TbShopAdDto.convertShopAdDoToDtoList(tbShopAds));
}
}

View File

@@ -12,6 +12,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
import com.chaozhanggui.system.cashierservice.entity.vo.IntegralFlowVo;
import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo;
import com.chaozhanggui.system.cashierservice.entity.vo.OpenMemberVo;
import com.chaozhanggui.system.cashierservice.service.UserService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
@@ -61,42 +62,56 @@ public class UserContoller {
// jsonObject.put("data",object);
// return jsonObject;
// }
@PostMapping("/openMember")
public Result openMember(@RequestBody OpenMemberVo memberVo){
return userService.openMember(memberVo);
}
@GetMapping("/shopUserInfo")
public Result shopUserInfo(@RequestParam("userId") String userId, @RequestHeader("openId") String openId, @RequestParam("shopId") String shopId) throws Exception {
if(shopId.equals("undefined")){
return Result.fail("店铺信息错误,请联系管理员!");
}
TbShopUser shopUser = new TbShopUser();
TbShopInfo tbShopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
TbShopInfo tbShopInfo = new TbShopInfo();
if (StringUtils.isNotBlank(shopId) && !shopId.equals("null")) {
shopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
tbShopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
if(tbShopInfo!=null){
shopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
// shopUser = shopUserMapper.selectByPhoneAndShopId(tbUserInfo.getTelephone(), shopId);
// if(ObjectUtil.isEmpty(shopUser)){
shopUser = new TbShopUser();
shopUser.setName(tbUserInfo.getNickName());
shopUser.setSex(tbUserInfo.getSex());
shopUser.setBirthDay(tbUserInfo.getBirthDay());
shopUser.setLevel(Byte.parseByte("1"));
String dynamicCode = RandomUtil.randomNumbers(8);
shopUser.setCode(dynamicCode);
shopUser.setTelephone(tbUserInfo.getTelephone());
shopUser.setAmount(BigDecimal.ZERO);
shopUser.setIsVip(Byte.parseByte("0"));
shopUser.setCreditAmount(BigDecimal.ZERO);
shopUser.setConsumeAmount(BigDecimal.ZERO);
shopUser.setConsumeNumber(0);
shopUser.setLevelConsume(BigDecimal.ZERO);
shopUser.setStatus(Byte.parseByte("1"));
shopUser.setShopId(shopId);
shopUser.setUserId(userId);
shopUser.setMiniOpenId(openId);
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser);
shopUser = new TbShopUser();
shopUser.setName(tbUserInfo.getNickName());
shopUser.setSex(tbUserInfo.getSex());
shopUser.setBirthDay(tbUserInfo.getBirthDay());
shopUser.setLevel(Byte.parseByte("1"));
String dynamicCode = RandomUtil.randomNumbers(8);
shopUser.setCode(dynamicCode);
shopUser.setTelephone(tbUserInfo.getTelephone());
shopUser.setAmount(BigDecimal.ZERO);
shopUser.setIsVip(Byte.parseByte("0"));
shopUser.setCreditAmount(BigDecimal.ZERO);
shopUser.setConsumeAmount(BigDecimal.ZERO);
shopUser.setConsumeNumber(0);
shopUser.setLevelConsume(BigDecimal.ZERO);
shopUser.setStatus(Byte.parseByte("1"));
shopUser.setShopId(shopId);
shopUser.setUserId(userId);
shopUser.setMiniOpenId(openId);
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser);
// }else {
// shopUser.setUserId(userId);
// shopUser.setUpdatedAt(System.currentTimeMillis());
// shopUserMapper.updateByPrimaryKey(shopUser);
// }
}
}else {
return Result.fail("店铺信息不存在");
}
} else {
shopUser.setAmount(BigDecimal.ZERO);
@@ -104,8 +119,9 @@ public class UserContoller {
if (tbShopInfo != null) {
shopUser.setIsUser(tbShopInfo.getIsCustom());
shopUser.setShopName(tbShopInfo.getShopName());
}else {
shopUser.setShopName("");
shopUser.setLng(tbShopInfo.getLng());
shopUser.setLat(tbShopInfo.getLat());
shopUser.setAddress(tbShopInfo.getAddress());
}
return Result.success(CodeEnum.SUCCESS, shopUser);
}
@@ -152,7 +168,9 @@ public class UserContoller {
* @return
*/
@GetMapping("/subQrCode")
public Result getSubQrCode(String shopId) throws Exception {
public Result getSubQrCode(
@RequestParam String shopId
) throws Exception {
String url = userService.getSubQrCode(shopId);
return Result.successWithData(url);
}