新建分支

This commit is contained in:
19991905653
2024-04-09 09:29:59 +08:00
parent 95405fa625
commit 342d0d82e1
47 changed files with 2392 additions and 109 deletions

View File

@@ -50,4 +50,28 @@ public class OrderController {
private void testMessage(@RequestParam("tableId") String tableId, @RequestParam("message") String message) throws IOException {
orderService.testMessage(tableId,message);
}
@GetMapping("/tradeIntegral")
private Result tradeIntegral(@RequestParam("userId") String userId, @RequestParam("id") String id) throws IOException {
return orderService.tradeIntegral(userId,id);
}
// @GetMapping("/我的积分")
// private Result mineYhq(@RequestParam("userId") String userId) throws IOException {
// return orderService.mineYhq(userId);
// }
@GetMapping("/mineCoupons")
private Result mineCoupons(@RequestHeader String token,@RequestParam("userId") String userId,@RequestParam("status") String status,
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
@RequestParam(value = "size", required = false, defaultValue = "1") Integer size) throws IOException {
return orderService.mineCoupons(userId,status,page,size);
}
@GetMapping("/findCoupons")
private Result findCoupons(@RequestHeader String token,
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
@RequestParam(value = "size", required = false, defaultValue = "1") Integer size) throws IOException {
return orderService.findCoupons(page,size);
}
@GetMapping("/findWiningUser")
private Result findWiningUser(){
return orderService.findWiningUser();
}
}

View File

@@ -0,0 +1,79 @@
package com.chaozhanggui.system.cashierservice.controller;
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbMerchantAccountMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount;
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
import com.chaozhanggui.system.cashierservice.entity.dto.AuthUserDto;
import com.chaozhanggui.system.cashierservice.entity.dto.OnlineUserDto;
import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo;
import com.chaozhanggui.system.cashierservice.entity.vo.OrderVo;
import com.chaozhanggui.system.cashierservice.service.LoginService;
import com.chaozhanggui.system.cashierservice.service.OnlineUserService;
import com.chaozhanggui.system.cashierservice.service.UserService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.IpUtil;
import com.chaozhanggui.system.cashierservice.util.MD5Utils;
import com.chaozhanggui.system.cashierservice.util.StringUtil;
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
@CrossOrigin(origins = "*")
@RestController
@Slf4j
@RequestMapping("user")
public class UserContoller {
@Autowired
UserService userService;
@Autowired
private TbShopUserMapper shopUserMapper;
@GetMapping("/userInfo")
public JSONObject userInfo(@RequestParam("openId") String openId ) throws Exception {
TbShopUser shopUser = shopUserMapper.selectByOpenId(openId);
JSONObject jsonObject = new JSONObject();
if (Objects.isNull(shopUser)){
jsonObject.put("status","fail");
jsonObject.put("msg","用户不存在");
return jsonObject;
}
String userSign = UUID.randomUUID().toString().replaceAll("-","");
String token = TokenUtil.generateJfToken(openId,userSign);
JSONObject object = new JSONObject();
object.put("token",token);
object.put("userSign",userSign);
object.put("num",shopUser.getLevelConsume());
jsonObject.put("status","success");
jsonObject.put("msg","成功");
jsonObject.put("data",object);
return jsonObject;
}
@PostMapping("/modityIntegral")
public JSONObject modityIntegral(@RequestHeader String token,@RequestBody IntegralVo integralVo ) throws Exception {
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userSign = jsonObject.getString("userSign");
return userService.modityIntegral(integralVo,userSign);
}
}

View File

@@ -0,0 +1,17 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbIntegralFlow;
public interface TbIntegralFlowMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbIntegralFlow record);
int insertSelective(TbIntegralFlow record);
TbIntegralFlow selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbIntegralFlow record);
int updateByPrimaryKey(TbIntegralFlow record);
}

View File

@@ -0,0 +1,23 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbIntegral;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public interface TbIntegralMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbIntegral record);
int insertSelective(TbIntegral record);
TbIntegral selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbIntegral record);
int updateByPrimaryKey(TbIntegral record);
List<TbIntegral> selectAllByUserId(String userId);
}

View File

@@ -0,0 +1,17 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbParams;
public interface TbParamsMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbParams record);
int insertSelective(TbParams record);
TbParams selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbParams record);
int updateByPrimaryKey(TbParams record);
}

View File

@@ -0,0 +1,17 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow;
public interface TbReleaseFlowMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbReleaseFlow record);
int insertSelective(TbReleaseFlow record);
TbReleaseFlow selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbReleaseFlow record);
int updateByPrimaryKey(TbReleaseFlow record);
}

View File

@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbParams;
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -25,4 +26,8 @@ public interface TbShopUserMapper {
TbShopUser selectByUserId(@Param("userId") String userId);
TbShopUser selectByOpenId(@Param("openId") String openId);
TbParams selectParams();
}

View File

@@ -0,0 +1,21 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons;
import java.util.List;
public interface TbSystemCouponsMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbSystemCoupons record);
int insertSelective(TbSystemCoupons record);
TbSystemCoupons selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbSystemCoupons record);
int updateByPrimaryKey(TbSystemCoupons record);
List<TbSystemCoupons> selectAll();
}

View File

@@ -0,0 +1,22 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbUserCoupons;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TbUserCouponsMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbUserCoupons record);
int insertSelective(TbUserCoupons record);
TbUserCoupons selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbUserCoupons record);
int updateByPrimaryKey(TbUserCoupons record);
List<TbUserCoupons> selectByUserId(@Param("userId") String userId,@Param("status") String status);
}

View File

@@ -0,0 +1,26 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbWiningUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface TbWiningUserMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbWiningUser record);
int insertSelective(TbWiningUser record);
TbWiningUser selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbWiningUser record);
int updateByPrimaryKey(TbWiningUser record);
List<TbWiningUser> selectAllByTrade(@Param("day") String day);
}

View File

@@ -0,0 +1,69 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
public class TbIntegral implements Serializable {
private Integer id;
private String userId;
private BigDecimal num;
private String status;
private Date createTime;
private Date updateTime;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
public BigDecimal getNum() {
return num;
}
public void setNum(BigDecimal num) {
this.num = num;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status == null ? null : status.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

View File

@@ -0,0 +1,59 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
public class TbIntegralFlow implements Serializable {
private Integer id;
private String userId;
private BigDecimal num;
private Date createTime;
private Date updateTime;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
public BigDecimal getNum() {
return num;
}
public void setNum(BigDecimal num) {
this.num = num;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

View File

@@ -95,6 +95,7 @@ public class TbOrderInfo implements Serializable {
private String remark;
private String tableName;
private String masterId;
private String isBuyCoupon;
private Integer totalNumber;
private List<TbOrderDetail> detailList;

View File

@@ -0,0 +1,38 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
public class TbParams implements Serializable {
private Integer id;
private BigDecimal integralRatio;
private BigDecimal tradeRatio;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public BigDecimal getIntegralRatio() {
return integralRatio;
}
public void setIntegralRatio(BigDecimal integralRatio) {
this.integralRatio = integralRatio;
}
public BigDecimal getTradeRatio() {
return tradeRatio;
}
public void setTradeRatio(BigDecimal tradeRatio) {
this.tradeRatio = tradeRatio;
}
}

View File

@@ -0,0 +1,79 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
public class TbReleaseFlow implements Serializable {
private Integer id;
private String userId;
private BigDecimal num;
private String type;
private String remark;
private String fromSource;
private Date createTime;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
public BigDecimal getNum() {
return num;
}
public void setNum(BigDecimal num) {
this.num = num;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public String getFromSource() {
return fromSource;
}
public void setFromSource(String fromSource) {
this.fromSource = fromSource == null ? null : fromSource.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@@ -0,0 +1,29 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class TbSystemCoupons implements Serializable {
private Integer id;
private String name;
private BigDecimal couponsPrice;
private BigDecimal couponsAmount;
private String status;
private Date createTime;
private Date updateTime;
private Integer dayNum;
private Date endTime;
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,89 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
public class TbUserCoupons implements Serializable {
private Integer id;
private String userId;
private BigDecimal couponsPrice;
private BigDecimal couponsAmount;
private String status;
private Date createTime;
private Date updateTime;
private Date endTime;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
public BigDecimal getCouponsPrice() {
return couponsPrice;
}
public void setCouponsPrice(BigDecimal couponsPrice) {
this.couponsPrice = couponsPrice;
}
public BigDecimal getCouponsAmount() {
return couponsAmount;
}
public void setCouponsAmount(BigDecimal couponsAmount) {
this.couponsAmount = couponsAmount;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status == null ? null : status.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}

View File

@@ -0,0 +1,25 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class TbWiningUser implements Serializable {
private Integer id;
private String userName;
private String orderNo;
private BigDecimal orderAmount;
private String isUser;
private String tradeDay;
private Date createTime;
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,19 @@
package com.chaozhanggui.system.cashierservice.entity.vo;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @author lyf
*/
@Data
public class IntegralVo {
private String openId;
private BigDecimal num;
private String type;
private String sign;
}

View File

@@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.interceptor;
import ch.qos.logback.classic.turbo.TurboFilter;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

View File

@@ -0,0 +1,41 @@
package com.chaozhanggui.system.cashierservice.rabbit;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
import com.chaozhanggui.system.cashierservice.service.CartService;
import com.chaozhanggui.system.cashierservice.service.IntegralService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
@Slf4j
@Component
@RabbitListener(queues = {RabbitConstants.INTEGRAL_QUEUE_PUT})
@Service
public class IntegralConsumer {
@Autowired
private RedisUtil redisUtil;
@Autowired
private IntegralService integralService;
@RabbitHandler
public void listener(String message) {
try {
JSONObject jsonObject = JSON.parseObject(message);
integralService.integralAdd(jsonObject);
} catch (Exception e) {
e.getMessage();
}
}
}

View File

@@ -61,7 +61,20 @@ public class RabbitConfig {
public Binding bindingPut_Register() {
return BindingBuilder.bind(queuePut_Register()).to(defaultExchange_Register()).with(RabbitConstants.CART_ROUTINGKEY_PUT);
}
@Bean
public DirectExchange defaultIntegral() {
return new DirectExchange(RabbitConstants.INTEGRAL_PUT);
}
@Bean
public Queue queueIntegral() {
return new Queue(RabbitConstants.INTEGRAL_QUEUE_PUT, true); //队列持久
}
@Bean
public Binding bindingIntegral() {
return BindingBuilder.bind(queueIntegral()).to(defaultIntegral()).with(RabbitConstants.INTEGRAL_ROUTINGKEY_PUT);
}

View File

@@ -29,4 +29,13 @@ public interface RabbitConstants {
public static final String PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT = "print_mechine_collect_routingkey_put_wx";
public static final String INTEGRAL_PUT="integral_put";
public static final String INTEGRAL_QUEUE_PUT = "integral_queue_put";
public static final String INTEGRAL_ROUTINGKEY_PUT = "integral_routingkey_put";
}

View File

@@ -36,7 +36,10 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, content, correlationId);
}
public void printCoupons(String content){
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.INTEGRAL_QUEUE_PUT, RabbitConstants.INTEGRAL_ROUTINGKEY_PUT, content, correlationId);
}
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
logger.info(" 回调id:" + correlationData);

View File

@@ -15,5 +15,5 @@ public class RedisCst {
public static final String TABLE_CART = "TABLE:CART:";
public static final String PRODUCT = "PRODUCT:";
public static final String INTEGRAL_COIN_KEY = "";
public static final String INTEGRAL_COIN_KEY = "INTEGRAL:COIN:KEY";
}

View File

@@ -1,5 +1,7 @@
package com.chaozhanggui.system.cashierservice.redis;
import com.chaozhanggui.system.cashierservice.socket.AppWebSocketServer;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -7,6 +9,7 @@ import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import java.io.*;
import java.util.*;
/**
@@ -17,7 +20,7 @@ import java.util.*;
* @Description redis工具类
*/
@Component
public class RedisUtil {
public class RedisUtil{
// 成功标识
private static final int REDIS_SUCCESS = 1;
// 失败标识
@@ -480,4 +483,128 @@ public class RedisUtil {
}
return REDIS_FAILED+"";
}
public byte[] serialize(Object obj) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
return bos.toByteArray();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public Object deserialize(byte[] bytes) {
try {
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bis);
return ois.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
// public String serialize(Object list) {
// try {
// ObjectMapper mapper = new ObjectMapper();
// return mapper.writeValueAsString(list);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
// public <T> List<AppWebSocketServer> deserializeJson(String json, Class<T> clazz) {
// try {
// ObjectMapper mapper = new ObjectMapper();
// return mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, clazz));
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
public byte[] getHashAll(String key) {
Jedis jedis = null;
try {
// 从jedis池中获取一个jedis实例
jedis = pool.getResource();
if (database!=0) {
jedis.select(database);
}
byte[] serializedList = jedis.get(key.getBytes());
return serializedList;
} catch (Exception e) {
e.printStackTrace();
} finally {
// 释放对象池即获取jedis实例使用后要将对象还回去
if (jedis != null) {
jedis.close();
}
}
return null;
}
public int saveHashAll(byte[] key,byte[] value) {
Jedis jedis = null;
try {
// 从jedis池中获取一个jedis实例
jedis = pool.getResource();
if (database!=0) {
jedis.select(database);
}
jedis.rpush(key,value);
return REDIS_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
} finally {
// 释放对象池即获取jedis实例使用后要将对象还回去
if (jedis != null) {
jedis.close();
}
}
return REDIS_FAILED;
}
public Set<String> getSet(String key ){
Jedis jedis = null ;
Set<String> set = null ;
try {
jedis = pool.getResource();
set = jedis.smembers(key);
}catch (Exception e) {
e.printStackTrace();
} finally {
// 释放对象池即获取jedis实例使用后要将对象还回去
if (jedis != null) {
jedis.close();
}
}
return set ;
}
/**
* 往set中添加数据
* @param key
* @param values
* @return
*/
public Long addSet(String key , String... values ){
Jedis jedis = null ;
try {
jedis = pool.getResource();
return jedis.sadd(key,values);
}catch (Exception e) {
e.printStackTrace();
} finally {
// 释放对象池即获取jedis实例使用后要将对象还回去
if (jedis != null) {
jedis.close();
}
}
return 0L ;
}
}

View File

@@ -16,6 +16,7 @@ import com.chaozhanggui.system.cashierservice.socket.AppWebSocketServer;
import com.chaozhanggui.system.cashierservice.socket.WebSocketServer;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.N;
import com.chaozhanggui.system.cashierservice.util.SnowFlakeUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -54,7 +55,10 @@ public class CartService {
private TbOrderDetailMapper orderDetailMapper;
@Autowired
private TbShopTableMapper shopTableMapper;
@Autowired
private TbUserCouponsMapper userCouponsMapper;
@Autowired
private TbSystemCouponsMapper systemCouponsMapper;
// @Transactional(rollbackFor = Exception.class)
public void createCart(JSONObject jsonObject) throws Exception {
@@ -202,23 +206,35 @@ public class CartService {
@Transactional(rollbackFor = Exception.class)
public void createOrder(JSONObject jsonObject) throws IOException {
try {
String shopId = jsonObject.getString("shopId");
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
//总金额
List<Integer> ids = new ArrayList<>();
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal packAMount = BigDecimal.ZERO;
BigDecimal originAmount = BigDecimal.ZERO;
BigDecimal saleAmount = BigDecimal.ZERO;
String couponId = "";
BigDecimal couponAmount = BigDecimal.ZERO;
Map<Integer, TbProductSku> skuMap = new HashMap<>();
List<TbOrderDetail> orderDetails = new ArrayList<>();
Integer orderId = 0;
TbMerchantAccount tbMerchantAccount = merchantAccountMapper.selectByShopId(jsonObject.getString("shopId"));
if (tbMerchantAccount == null) {
throw new MsgException("生成订单错误");
}
String userId = jsonObject.getString("userId");
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
if (tbUserInfo == null) {
throw new MsgException("生成订单失败");
}
for (int i = 0; i < array.size(); i++) {
JSONObject object = array.getJSONObject(i);
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
TbProductSkuWithBLOBs tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
packAMount = packAMount.add(cashierCart.getPackFee());
originAmount = originAmount.add(cashierCart.getTotalAmount());
if (Objects.nonNull(tbProduct)) {
saleAmount = saleAmount.add(tbProduct.getSalePrice());
}
@@ -249,108 +265,186 @@ public class CartService {
orderId = Integer.valueOf(cashierCart.getOrderId());
}
}
TbMerchantAccount tbMerchantAccount = merchantAccountMapper.selectByShopId(jsonObject.getString("shopId"));
if (tbMerchantAccount == null) {
throw new MsgException("生成订单错误");
}
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(jsonObject.getInteger("userId"));
if (tbUserInfo == null) {
throw new MsgException("生成订单失败");
}
//总金额
TbShopTable shopTable = shopTableMapper.selectQRcode(jsonObject.getString("tableId"));
//生成订单
TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId);
if (Objects.nonNull(orderInfo)) {
log.info("订单状态:" + orderInfo.getStatus());
if (!"unpaid".equals(orderInfo.getStatus())) {
log.info("开始处理订单");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "订单正在支付中,请稍后再试");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", "");
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
log.info("消息推送");
return;
String isBuyYhq = "false";
if (jsonObject.containsKey("isYhq")){
//1:购买优惠券0自己持有优惠券
Integer couponsId = jsonObject.getInteger("couponsId");
if (jsonObject.getString("isBuyYhq").equals("1")){
TbSystemCoupons systemCoupons = systemCouponsMapper.selectByPrimaryKey(couponsId);
if (Objects.isNull(systemCoupons) || !systemCoupons.getStatus().equals("0")){
log.info("开始处理订单");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "优惠券已售空");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", "");
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
log.info("消息推送");
return;
}
if (N.gt(systemCoupons.getCouponsAmount(),totalAmount)){
log.info("开始处理订单");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "订单金额小于优惠价金额");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", "");
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
log.info("消息推送");
return;
}
totalAmount = totalAmount.add(systemCoupons.getCouponsPrice()).subtract(systemCoupons.getCouponsAmount());
originAmount = originAmount.add(systemCoupons.getCouponsPrice());
systemCoupons.setStatus("1");
systemCouponsMapper.updateByPrimaryKeySelective(systemCoupons);
TbUserCoupons userCoupons = new TbUserCoupons();
userCoupons.setEndTime(DateUtils.getNewDate(new Date(),3,systemCoupons.getDayNum()));
userCoupons.setCouponsAmount(systemCoupons.getCouponsAmount());
userCoupons.setCouponsPrice(systemCoupons.getCouponsPrice());
userCoupons.setStatus("1");
userCoupons.setUserId(userId);
userCoupons.setCreateTime(new Date());
userCouponsMapper.insert(userCoupons);
couponId = userCoupons.getId()+"";
couponAmount = userCoupons.getCouponsAmount();
}else {
TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(couponsId);
if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0")){
log.info("开始处理订单");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "优惠券已使用");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", "");
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
log.info("消息推送");
return;
}
if (N.gt(userCoupons.getCouponsAmount(),totalAmount)){
log.info("开始处理订单");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "订单金额小于优惠价金额");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", "");
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
log.info("消息推送");
return;
}
totalAmount = totalAmount.subtract(userCoupons.getCouponsAmount());
userCoupons.setStatus("1");
userCoupons.setEndTime(DateUtils.getNewDate(new Date(),5,30));
userCouponsMapper.updateByPrimaryKeySelective(userCoupons);
}
}else {
if (Objects.nonNull(orderInfo)) {
log.info("订单状态:" + orderInfo.getStatus());
if (!"unpaid".equals(orderInfo.getStatus())) {
log.info("开始处理订单");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "订单正在支付中,请稍后再试");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", "");
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
log.info("消息推送");
return;
}
orderDetailMapper.deleteByOUrderId(orderId);
orderInfo.setUpdatedAt(System.currentTimeMillis());
orderInfo.setSettlementAmount(totalAmount);
orderInfo.setAmount(totalAmount);
orderInfo.setOriginAmount(totalAmount);
orderInfo.setOrderAmount(totalAmount.add(packAMount));
orderInfo.setFreightAmount(BigDecimal.ZERO);
orderInfo.setProductAmount(saleAmount);
orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
} else {
orderInfo = new TbOrderInfo();
String orderNo = generateOrderNumber();
orderInfo.setOrderNo(orderNo);
orderInfo.setSettlementAmount(totalAmount);
orderInfo.setPackFee(packAMount);
orderInfo.setOriginAmount(totalAmount);
orderInfo.setProductAmount(totalAmount);
orderInfo.setAmount(totalAmount);
orderInfo.setOrderAmount(totalAmount.add(packAMount));
orderInfo.setPayAmount(BigDecimal.ZERO);
orderInfo.setRefundAmount(new BigDecimal("0.00"));
orderInfo.setTableId(jsonObject.getString("tableId"));
orderInfo.setSendType("table");
orderInfo.setOrderType("miniapp");
orderInfo.setTradeDay(DateUtils.getDay());
orderInfo.setStatus("unpaid");
orderInfo.setShopId(jsonObject.getString("shopId"));
orderInfo.setUserId(jsonObject.getString("userId"));
orderInfo.setCreatedAt(Instant.now().toEpochMilli());
orderInfo.setSystemTime(Instant.now().toEpochMilli());
orderInfo.setUpdatedAt(Instant.now().toEpochMilli());
orderInfo.setIsAccepted((byte) 1);
if (Objects.nonNull(shopTable)) {
orderInfo.setTableName(shopTable.getName());
orderDetailMapper.deleteByOUrderId(orderId);
orderInfo.setUpdatedAt(System.currentTimeMillis());
orderInfo.setSettlementAmount(totalAmount);
orderInfo.setUserCouponId(couponId);
orderInfo.setUserCouponAmount(couponAmount);
orderInfo.setAmount(totalAmount);
orderInfo.setOriginAmount(originAmount);
orderInfo.setOrderAmount(totalAmount.add(packAMount));
orderInfo.setFreightAmount(BigDecimal.ZERO);
orderInfo.setProductAmount(saleAmount);
orderInfo.setUserCouponId(couponId);
orderInfo.setIsBuyCoupon(isBuyYhq);
orderInfo.setUserCouponAmount(couponAmount);
orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
} else {
orderInfo.setMerchantId(String.valueOf(tbMerchantAccount.getId()));
orderInfo = getOrder(totalAmount,packAMount,shopTable,tbMerchantAccount.getId().toString(),jsonObject,originAmount);
orderInfo.setUserCouponId(couponId);
orderInfo.setOriginAmount(originAmount);
orderInfo.setIsBuyCoupon(isBuyYhq);
orderInfo.setUserCouponAmount(couponAmount);
orderInfoMapper.insert(orderInfo);
orderId = orderInfo.getId();
}
orderInfo.setMerchantId(String.valueOf(tbMerchantAccount.getId()));
orderInfoMapper.insert(orderInfo);
orderId = orderInfo.getId();
}
for (TbOrderDetail orderDetail : orderDetails) {
orderDetail.setOrderId(orderId);
orderDetailMapper.insert(orderDetail);
}
for (int i = 0; i < array.size(); i++) {
JSONObject object = array.getJSONObject(i);
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCart.setOrderId(orderId + "");
cashierCart.setStatus("closed");
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
object.put("updatedAt", System.currentTimeMillis());
object.put("orderId", orderId + "");
}
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId), array.toJSONString());
orderInfo.setDetailList(orderDetails);
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "success");
jsonObject1.put("msg", "成功");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", orderInfo);
redisUtil.deleteByKey(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId));
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
JSONObject jsonObject12 = new JSONObject();
jsonObject12.put("status", "success");
jsonObject12.put("msg", "成功");
jsonObject12.put("type", "order");
jsonObject12.put("amount", BigDecimal.ZERO);
for (TbOrderDetail orderDetail : orderDetails) {
orderDetail.setOrderId(orderId);
orderDetailMapper.insert(orderDetail);
}
for (int i = 0; i < array.size(); i++) {
JSONObject object = array.getJSONObject(i);
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCart.setOrderId(orderId + "");
cashierCart.setStatus("closed");
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
object.put("updatedAt", System.currentTimeMillis());
object.put("orderId", orderId + "");
}
redisUtil.saveMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId), array.toJSONString());
orderInfo.setDetailList(orderDetails);
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "success");
jsonObject1.put("msg", "成功");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", orderInfo);
redisUtil.deleteByKey(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId")).concat("-").concat(shopId));
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("userId"), true);
JSONObject jsonObject12 = new JSONObject();
jsonObject12.put("status", "success");
jsonObject12.put("msg", "成功");
jsonObject12.put("type", "order");
jsonObject12.put("amount", BigDecimal.ZERO);
jsonObject12.put("data", new JSONArray());
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId), false);
jsonObject12.put("data", new JSONArray());
AppWebSocketServer.AppSendInfo(jsonObject12, jsonObject.getString("tableId").concat("-").concat(shopId), false);
}
} catch (Exception e) {
e.getMessage();
}
}
private TbOrderInfo getOrder(BigDecimal totalAmount, BigDecimal packAMount,
TbShopTable shopTable, String merchantId, JSONObject jsonObject, BigDecimal originAmount){
TbOrderInfo orderInfo = new TbOrderInfo();
String orderNo = generateOrderNumber();
orderInfo.setOrderNo(orderNo);
orderInfo.setSettlementAmount(totalAmount);
orderInfo.setPackFee(packAMount);
orderInfo.setOriginAmount(originAmount);
orderInfo.setProductAmount(totalAmount);
orderInfo.setAmount(totalAmount);
orderInfo.setOrderAmount(totalAmount.add(packAMount));
orderInfo.setPayAmount(BigDecimal.ZERO);
orderInfo.setRefundAmount(new BigDecimal("0.00"));
orderInfo.setTableId(jsonObject.getString("tableId"));
orderInfo.setSendType("table");
orderInfo.setOrderType("miniapp");
orderInfo.setTradeDay(DateUtils.getDay());
orderInfo.setStatus("unpaid");
orderInfo.setShopId(jsonObject.getString("shopId"));
orderInfo.setUserId(jsonObject.getString("userId"));
orderInfo.setCreatedAt(Instant.now().toEpochMilli());
orderInfo.setSystemTime(Instant.now().toEpochMilli());
orderInfo.setUpdatedAt(Instant.now().toEpochMilli());
orderInfo.setIsAccepted((byte) 1);
if (Objects.nonNull(shopTable)) {
orderInfo.setTableName(shopTable.getName());
}
orderInfo.setMerchantId(merchantId);
return orderInfo;
}
public String generateOrderNumber() {
String date = DateUtils.getSdfTimes();
Random random = new Random();

View File

@@ -0,0 +1,90 @@
package com.chaozhanggui.system.cashierservice.service;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.*;
/**
* @author lyf
*/
@Service
@Slf4j
public class IntegralService {
@Autowired
private RedisUtil redisUtil;
@Autowired
private TbOrderInfoMapper orderInfoMapper;
@Autowired
private TbCashierCartMapper cashierCartMapper;
@Autowired
private TbProductMapper productMapper;
@Autowired
private TbProductSkuMapper productSkuMapper;
@Autowired
private TbShopInfoMapper shopInfoMapper;
@Autowired
private TbShopUserMapper tbShopUserMapper;
@Resource
private TbReleaseFlowMapper integralFlowMapper;
@Autowired
private TbUserCouponsMapper userCouponsMapper;
@Transactional(rollbackFor = Exception.class)
public void integralAdd(JSONObject jsonObject) throws ParseException {
String type = jsonObject.getString("type");
if (type.equals("trade")){
//优惠券兑换积分
Integer integralId = jsonObject.getInteger("integralId");
TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(integralId);
if (Objects.isNull(userCoupons) || !"0".equals(userCoupons.getStatus())){
throw new MsgException("优惠券已被使用");
}
userCoupons.setStatus("trade");
userCoupons.setUpdateTime(new Date());
userCouponsMapper.updateByPrimaryKeySelective(userCoupons);
TbParams params = tbShopUserMapper.selectParams();
TbReleaseFlow integralFlow = new TbReleaseFlow();
integralFlow.setNum(userCoupons.getCouponsAmount().multiply(params.getTradeRatio()));
integralFlow.setCreateTime(new Date());
integralFlow.setFromSource(userCoupons.getId()+"");
integralFlow.setType("TRADEADD");
integralFlow.setUserId(userCoupons.getUserId());
integralFlowMapper.insert(integralFlow);
}else {
Integer orderId = jsonObject.getInteger("orderId");
TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId);
if (Objects.isNull(orderInfo)) {
throw new MsgException("该订单不存在");
}
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
if (Objects.isNull(shopInfo) || !"true".equals(shopInfo.getIsOpenYhq())){
throw new MsgException("该店铺未开启优惠券功能");
}
TbParams params = tbShopUserMapper.selectParams();
TbUserCoupons userCoupons = new TbUserCoupons();
userCoupons.setUserId(orderInfo.getUserId());
userCoupons.setCouponsAmount(orderInfo.getPayAmount().multiply(params.getIntegralRatio()));
userCoupons.setStatus("0");
userCoupons.setCouponsPrice(userCoupons.getCouponsAmount().multiply(new BigDecimal("0.5")));
userCoupons.setCreateTime(new Date());
userCoupons.setEndTime(DateUtils.getNewDate(new Date(),3,30));
//执行插入方法
userCouponsMapper.insert(userCoupons);
}
}
}

View File

@@ -0,0 +1,134 @@
package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Service
public class UserService {
@Autowired
private TbShopUserMapper shopUserMapper;
@Autowired
private TbReleaseFlowMapper releaseFlowMapper;
@Autowired
RedisUtils redisUtils;
public JSONObject modityIntegral(IntegralVo integralVo, String userSign) {
JSONObject object = (JSONObject) JSONObject.toJSON(integralVo);
if (N.gt(BigDecimal.ZERO, integralVo.getNum())) {
JSONObject result = new JSONObject();
result.put("status", "fail");
result.put("msg", "积分数量不允许小于0");
result.put("data", "");
return result;
}
object.put("userSign", userSign);
JSONObject jsonObject = JSONUtil.sortJSONObject(object, CacheMap.map);
System.out.println(jsonObject.toJSONString());
String sign = MD5Util.encrypt(jsonObject.toJSONString());
if (!sign.equals(integralVo.getSign())) {
JSONObject result = new JSONObject();
result.put("status", "fail");
result.put("msg", "签名验证失败");
result.put("data", "");
return result;
}
TbShopUser shopUser = shopUserMapper.selectByOpenId(integralVo.getOpenId());
if (Objects.isNull(shopUser)) {
JSONObject result = new JSONObject();
result.put("status", "fail");
result.put("msg", "用户不存在");
result.put("data", "");
return result;
}
boolean falg = updateIntegral(shopUser.getId(), integralVo.getNum(), integralVo.getType());
if (!falg) {
JSONObject result = new JSONObject();
result.put("status", "fail");
result.put("msg", "余额不足");
result.put("data", "");
return result;
}
JSONObject result = new JSONObject();
result.put("status", "success");
result.put("msg", "操作成功");
return result;
}
public static void main(String[] args) {
IntegralVo integralVo = new IntegralVo();
integralVo.setNum(new BigDecimal("5254"));
integralVo.setOpenId("or1l864NBOoJZhC5x_yeziZ26j6c");
integralVo.setType("sub");
JSONObject object = (JSONObject) JSONObject.toJSON(integralVo);
object.put("userSign", "02c03d79c36b4c01b217ffb1baef9009");
JSONObject jsonObject = JSONUtil.sortJSONObject(object, CacheMap.map);
System.out.println("加密前字符串:" + jsonObject.toJSONString());
String sign = MD5Util.encrypt(jsonObject.toJSONString());
System.out.println("加密后签名:" + sign);
}
private Boolean updateIntegral(String userId, BigDecimal num, String type) {
boolean lock_coin = redisUtils.lock(RedisCst.INTEGRAL_COIN_KEY + userId, 5000, TimeUnit.MILLISECONDS);
if (lock_coin) {
TbShopUser tbShopUser = shopUserMapper.selectByPrimaryKey(userId);
boolean flag = true;
if (type.equals("sub")) {
if (N.gt(num, tbShopUser.getLevelConsume())) {
flag = false;
} else {
tbShopUser.setLevelConsume(tbShopUser.getLevelConsume().subtract(num));
}
} else if (type.equals("add")) {
tbShopUser.setLevelConsume(tbShopUser.getLevelConsume().add(num));
}
if (flag) {
if (type.equals("sub")) {
TbReleaseFlow releaseFlow = new TbReleaseFlow();
releaseFlow.setNum(num);
releaseFlow.setCreateTime(new Date());
releaseFlow.setFromSource("OWER");
releaseFlow.setType("BUYSUB");
releaseFlow.setUserId(userId);
releaseFlowMapper.insert(releaseFlow);
}else if (type.equals("sub")){
TbReleaseFlow releaseFlow = new TbReleaseFlow();
releaseFlow.setNum(num);
releaseFlow.setCreateTime(new Date());
releaseFlow.setFromSource("OWER");
releaseFlow.setType("THREEADD");
releaseFlow.setUserId(userId);
releaseFlowMapper.insert(releaseFlow);
}
shopUserMapper.updateByPrimaryKeySelective(tbShopUser);
}
redisUtils.releaseLock(RedisCst.INTEGRAL_COIN_KEY + userId);
return flag;
} else {
return updateIntegral(userId, num, type);
}
}
}

View File

@@ -23,7 +23,7 @@ import javax.annotation.Resource;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@@ -105,11 +105,24 @@ public class AppWebSocketServer {
if (webSocketMap.containsKey(tableId + "-" + shopId)) {
List<AppWebSocketServer> serverList = webSocketMap.get(tableId + "-" + shopId);
serverList.add(this);
} else {
List<AppWebSocketServer> serverList = new ArrayList<>();
serverList.add(this);
webSocketMap.put(tableId + "-" + shopId, serverList);
}
SocketSession socketSession = new SocketSession();
socketSession.setSession(session);
socketSession.setShopId(shopId);
socketSession.setTableId(tableId);
socketSession.setUserId(userId);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(session);
byte[] sessionData = bos.toByteArray();
// 将序列化后的会话数据存储到Redis中
redisUtils.saveHashAll(session.getId().getBytes(), sessionData);
if (userMap.containsKey(tableId + "-" + shopId)) {
Set<String> userSet = userMap.get(tableId + "-" + shopId);
userSet.add(userId);
@@ -311,4 +324,26 @@ public class AppWebSocketServer {
public static synchronized ConcurrentHashMap<String, List<JSONObject>> getRecordMap() {
return AppWebSocketServer.recordMap;
}
private byte[] serialize(Object obj) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
return bos.toByteArray();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private Object deserialize(byte[] bytes) {
try {
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bis);
return ois.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
}

View File

@@ -0,0 +1,311 @@
//package com.chaozhanggui.system.cashierservice.socket;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.chaozhanggui.system.cashierservice.config.WebSocketCustomEncoding;
//import com.chaozhanggui.system.cashierservice.dao.TbShopTableMapper;
//import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
//import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
//import com.chaozhanggui.system.cashierservice.redis.RedisCst;
//import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
//import com.chaozhanggui.system.cashierservice.util.SpringUtils;
//import lombok.Data;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//import javax.websocket.*;
//import javax.websocket.server.PathParam;
//import javax.websocket.server.ServerEndpoint;
//import java.io.IOException;
//import java.math.BigDecimal;
//import java.util.*;
//import java.util.concurrent.ConcurrentHashMap;
//import java.util.concurrent.atomic.AtomicBoolean;
//
//@ServerEndpoint(value = "/websocket/table/{tableId}/{shopId}/{userId}", encoders = WebSocketCustomEncoding.class)
//@Component
//@Slf4j
//@Data
//public class AppWebSocketServerCopy {
//
//
// @Resource
// private RabbitProducer a;
//
// //注入为空
// public static RabbitProducer rabbitProducer;
//
// @PostConstruct
// public void b() {
// rabbitProducer = this.a;
// }
//
//
// private RedisUtil redisUtils = SpringUtils.getBean(RedisUtil.class);
// private TbShopTableMapper shopTableMapper = SpringUtils.getBean(TbShopTableMapper.class);
// /**
// * concurrent包的线程安全Set用来存放每个客户端对应的MyWebSocket对象。
// */
// //一个 AppWebSocketServer 就是一个用户一个tableId下有一个 List<AppWebSocketServer> 也就是多个用户
// private static ConcurrentHashMap<String, List<AppWebSocketServerCopy>> webSocketMap = new ConcurrentHashMap<>();
// public static ConcurrentHashMap<String, Set<String>> userMap = new ConcurrentHashMap<>();
// private static ConcurrentHashMap<String, AppWebSocketServerCopy> userSocketMap = new ConcurrentHashMap<>();
// //购物车的记录,用于第一次扫码的人同步购物车
// private static ConcurrentHashMap<String, List<JSONObject>> recordMap = new ConcurrentHashMap<>();
// private static ConcurrentHashMap<String, Session> sessionMap = new ConcurrentHashMap<>();
//
// /**
// * 与某个客户端的连接会话,需要通过它来给客户端发送数据
// */
// private Session session;
//
// /**
// * 接收tableId
// */
// private String tableId = "";
// private String shopId = "";
// private String userId = "";
//
// /**
// * 用来标识这个用户需要接收同步的购物车信息
// */
// private volatile AtomicBoolean sync = new AtomicBoolean(true);
//
// private volatile AtomicBoolean createOrder = new AtomicBoolean(false);
//
//
// /**
// * 连接建立成功调用的方法
// */
// @OnOpen
// public void onOpen(Session session, @PathParam("tableId") String tableId, @PathParam("shopId") String shopId, @PathParam("userId") String userId) {
// this.session = session;
// this.tableId = tableId;
// this.shopId = shopId;
// this.userId = userId;
// try {
// TbShopTable shopTable = shopTableMapper.selectQRcode(tableId);
// if (Objects.isNull(shopTable)) {
// JSONObject jsonObject1 = new JSONObject();
// jsonObject1.put("status", "fail");
// jsonObject1.put("msg", "桌码不存在");
// jsonObject1.put("type", "addCart");
// jsonObject1.put("data", new ArrayList<>());
// jsonObject1.put("amount", BigDecimal.ZERO);
// sendMessage(jsonObject1);
// onClose();
// }
// if (webSocketMap.containsKey(tableId + "-" + shopId)) {
// List<AppWebSocketServerCopy> serverList = webSocketMap.get(tableId + "-" + shopId);
// serverList.add(this);
// } else {
// List<AppWebSocketServerCopy> serverList = new ArrayList<>();
// serverList.add(this);
// webSocketMap.put(tableId + "-" + shopId, serverList);
// }
// if (userMap.containsKey(tableId + "-" + shopId)) {
// Set<String> userSet = userMap.get(tableId + "-" + shopId);
// userSet.add(userId);
// } else {
// Set<String> userSet = new HashSet<>();
// userSet.add(userId);
// userMap.put(tableId + "-" + shopId,userSet);
// }
//
// userSocketMap.put(userId, this);
//// sessionMap.put(userId,session);
// String mes = redisUtils.getMessage(RedisCst.TABLE_CART.concat(tableId + "-" + shopId));
// if (StringUtils.isEmpty(mes)) {
// JSONObject jsonObject1 = new JSONObject();
// jsonObject1.put("status", "success");
// jsonObject1.put("msg", "成功");
// jsonObject1.put("type", "addCart");
// jsonObject1.put("data", new ArrayList<>());
// jsonObject1.put("amount", BigDecimal.ZERO);
// sendMessage(jsonObject1);
// } else {
// JSONObject jsonObject1 = new JSONObject();
// jsonObject1.put("status", "success");
// jsonObject1.put("msg", "成功");
// jsonObject1.put("type", "addCart");
// BigDecimal amount = BigDecimal.ZERO;
// JSONArray jsonArray = JSON.parseArray(redisUtils.getMessage(RedisCst.TABLE_CART.concat(tableId + "-" + shopId)));
// for (int i = 0; i < jsonArray.size(); i++) {
// JSONObject object = jsonArray.getJSONObject(i);
// amount = amount.add(object.getBigDecimal("totalAmount"));
// }
// jsonObject1.put("amount", amount);
// jsonObject1.put("data", jsonArray);
// sendMessage(jsonObject1);
// }
//// sendMessage(recordMap.get(tableId));
// } catch (IOException e) {
// log.error("用户:" + tableId + ",网络异常!!!!!!");
// }
// }
//
// /**
// * 连接关闭调用的方法
// */
// @OnClose
// public void onClose() {
// if (webSocketMap.containsKey(tableId + "-" + shopId)) {
// List<AppWebSocketServerCopy> serverList = webSocketMap.get(tableId + "-" + shopId);
// if (serverList.isEmpty()) {
// webSocketMap.remove(tableId + "-" + shopId);
// }
// serverList.remove(this);
//
// }
// if (userMap.containsKey(tableId + "-" + shopId)){
// Set<String> userSet = userMap.get(tableId + "-" + shopId);
// if (userSet.isEmpty()){
// userMap.remove(tableId + "-" + shopId);
// }
// userSet.remove(userId);
// }
// }
// public static void onClosed(String user) throws IOException {
// Session session1 = sessionMap.get(user);
// session1.close();
// }
// /**
// * 收到客户端消息后调用的方法
// *
// * @param message 客户端发送过来的消息
// */
// @OnMessage
// public void onMessage(String message, Session session) {
//
// System.out.println(message);
// //可以群发消息
// //消息保存到数据库、redis
// if (StringUtils.isNotBlank(message) && !message.equals("undefined")) {
// try {
// //解析发送的报文
// JSONObject jsonObject = new JSONObject();
// if (StringUtils.isNotEmpty(message)) {
// jsonObject = JSONObject.parseObject(message);
// }
// //追加发送人(防止串改)
// jsonObject.put("tableId", this.tableId);
// jsonObject.put("shopId", this.shopId);
//
// //这里采用责任链模式,每一个处理器对应一个前段发过来的请,这里还可以用工厂模式来生成对象
//// ChangeHandler changeHandler = new ChangeHandler();
//// CreateOrderHandler createOrderHandler = new CreateOrderHandler();
//// SyncHandler syncHandler = new SyncHandler();
//// ClearHandler clearHandler = new ClearHandler();
//// OtherHandler otherHandler = new OtherHandler();
////
//// changeHandler.addNextHandler(syncHandler).addNextHandler(createOrderHandler).addNextHandler(clearHandler).addNextHandler(otherHandler);
//// changeHandler.handleRequest(webSocketMap,jsonObject,recordMap,this);
// if ("sku".equals(jsonObject.getString("type"))){
// boolean exist = redisUtils.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)));
// Integer num = 0;
// if (exist){
// JSONArray array = JSON.parseArray(redisUtils.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
// for (int i = 0; i < array.size(); i++) {
// JSONObject object = array.getJSONObject(i);
// if (object.getString("skuId").equals(jsonObject.getString("skuId"))) {
// num = object.getIntValue("totalNumber");
// break;
// }
// }
// }
// JSONObject jsonObject1 = new JSONObject();
// jsonObject1.put("status", "success");
// jsonObject1.put("msg", "成功");
// jsonObject1.put("type", "sku");
// jsonObject1.put("data", new ArrayList<>());
// jsonObject1.put("amount", num);
// sendMessage(jsonObject1);
// }else {
// rabbitProducer.putCart(jsonObject.toJSONString());
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// /**
// * 发生错误时候
// *
// * @param session
// * @param error
// */
// @OnError
// public void onError(Session session, Throwable error) {
// log.error("用户错误:" + this.tableId + ",原因:" + error.getMessage());
// error.printStackTrace();
// }
//
// /**
// * 实现服务器主动推送
// */
// public void sendMessage(Object message) throws IOException {
// //加入线程锁
// synchronized (session) {
// try {
// //同步发送信息
// this.session.getBasicRemote().sendObject(message);
// } catch (Exception e) {
// log.error("服务器推送失败:" + e.getMessage());
// }
// }
// }
//
//
// /**
// * 发送自定义消息
// * */
// /**
// * 发送自定义消息
// *
// * @param message 发送的信息
// * @param tableId 如果为null默认发送所有
// * @throws IOException
// */
// public static void AppSendInfo(Object message, String tableId, boolean userFlag) throws IOException {
// if (userFlag) {
// if (userSocketMap.containsKey(tableId)) {
// AppWebSocketServerCopy server = userSocketMap.get(tableId);
// server.sendMessage(message);
// } else {
// log.error("请求的userId:" + tableId + "不在该服务器上");
// }
// } else {
// if (StringUtils.isEmpty(tableId)) {
// // 向所有用户发送信息
// for (List<AppWebSocketServerCopy> serverList : webSocketMap.values()) {
// for (AppWebSocketServerCopy server : serverList) {
// server.sendMessage(message);
// }
// }
// } else if (webSocketMap.containsKey(tableId)) {
// // 发送给指定用户信息
// List<AppWebSocketServerCopy> serverList = webSocketMap.get(tableId);
// for (AppWebSocketServerCopy server : serverList) {
// server.sendMessage(message);
// }
// } else {
// log.error("请求的tableId:" + tableId + "不在该服务器上");
// }
// }
//
// }
//
//
// public static synchronized ConcurrentHashMap<String, List<AppWebSocketServerCopy>> getWebSocketMap() {
// return AppWebSocketServerCopy.webSocketMap;
// }
//
// public static synchronized ConcurrentHashMap<String, List<JSONObject>> getRecordMap() {
// return AppWebSocketServerCopy.recordMap;
// }
//}

View File

@@ -0,0 +1,14 @@
package com.chaozhanggui.system.cashierservice.socket;
import lombok.Data;
import javax.websocket.Session;
import java.io.Serializable;
@Data
public class SocketSession implements Serializable {
private Session session;
private String tableId ;
private String shopId ;
private String userId ;
}

View File

@@ -0,0 +1,28 @@
package com.chaozhanggui.system.cashierservice.task;
import com.chaozhanggui.system.cashierservice.dao.TbWiningUserMapper;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class TaskScheduler {
@Autowired
private TbWiningUserMapper tbWiningUserMapper;
//更新订单状态
// @Scheduled(fixedRate = 1000, initialDelay = 5000)
public void orderStatus() throws InterruptedException {
System.out.println(DateUtils.getTime());
Thread.sleep(10000);
}
// @Scheduled(fixedRate = 1000)
public void winningUser(){
System.out.println("恭喜您中奖了"+DateUtils.getTime());
}
}

View File

@@ -0,0 +1,10 @@
package com.chaozhanggui.system.cashierservice.util;
import java.util.HashMap;
import java.util.Map;
public interface CacheMap {
Map<String,String> map = new HashMap(){{
put("sign","1");
}};
}

View File

@@ -0,0 +1,50 @@
package com.chaozhanggui.system.cashierservice.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
public class WiningUtil {
private List<String> participants;
private Random random;
public WiningUtil(List<String> participants) {
this.participants = participants;
this.random = new Random();
}
public String drawWinner() {
if (participants.isEmpty()) {
return "No participants to draw from";
}
int index = random.nextInt(participants.size());
return participants.get(index);
}
public static void main(String[] args) {
// 参与抽奖的人员名单
List<String> participants = new ArrayList<>();
participants.add("Alice");
participants.add("Bob");
participants.add("Charlie");
participants.add("David");
participants.add("Eve");
// 创建抽奖对象
WiningUtil winingUtil = new WiningUtil(participants);
// 进行抽奖
String winner = winingUtil.drawWinner();
System.out.println("Winner: " + winner);
}
public static boolean winingresult(){
return false;
}
}

View File

@@ -54,6 +54,8 @@ ysk:
callBackurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBack
callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack
default: 18710449883
server:
port: 9889

View File

@@ -1,5 +1,5 @@
server:
port: 9888
port: 9889
spring:
datasource:
url: jdbc:mysql://rm-bp1b572nblln4jho2.mysql.rds.aliyuncs.com/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false

View File

@@ -1,5 +1,5 @@
server:
port: 9889
# port: 9889
servlet:
context-path: /cashierService/
wx:

View File

@@ -6,7 +6,7 @@
<generatorConfiguration>
<!-- 需要指明数据库连接器的绝对路径 -->
<!-- <classPathEntry location="C:\Users\admin\.m1\repository\mysql\mysql-connector-java\8.0.20\mysql-connector-java-8.0.20.jar" />-->
<classPathEntry location="D:\.m2\repository\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar"/>
<classPathEntry location="E:\app\maven\repository\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar"/>
<context id="msqlTables" targetRuntime="MyBatis3">
<!-- 生成的pojo将implements Serializable-->
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>
@@ -52,13 +52,9 @@
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<table tableName="tb_token" domainObjectName="TbToken"
<table tableName="tb_wining_user" domainObjectName="TbWiningUser"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" >
</table>
</context>
</generatorConfiguration>

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbIntegralFlowMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbIntegralFlow">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="num" jdbcType="DECIMAL" property="num" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
id, user_id, num, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_integral_flow
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_integral_flow
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbIntegralFlow">
insert into tb_integral_flow (id, user_id, num,
create_time, update_time)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{num,jdbcType=DECIMAL},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbIntegralFlow">
insert into tb_integral_flow
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="num != null">
num,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="num != null">
#{num,jdbcType=DECIMAL},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbIntegralFlow">
update tb_integral_flow
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="num != null">
num = #{num,jdbcType=DECIMAL},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbIntegralFlow">
update tb_integral_flow
set user_id = #{userId,jdbcType=VARCHAR},
num = #{num,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbIntegralMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbIntegral">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="num" jdbcType="DECIMAL" property="num" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
id, user_id, num, status, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_integral
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAllByUserId" resultType="com.chaozhanggui.system.cashierservice.entity.TbIntegral">
select * from tb_integral where user_id = #{userId} and status = 'CREATE'
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_integral
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbIntegral">
insert into tb_integral (id, user_id, num,
status, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{num,jdbcType=DECIMAL},
#{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbIntegral">
insert into tb_integral
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="num != null">
num,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="num != null">
#{num,jdbcType=DECIMAL},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbIntegral">
update tb_integral
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="num != null">
num = #{num,jdbcType=DECIMAL},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbIntegral">
update tb_integral
set user_id = #{userId,jdbcType=VARCHAR},
num = #{num,jdbcType=DECIMAL},
status = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@@ -46,6 +46,7 @@
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="master_id" jdbcType="VARCHAR" property="masterId"/>
<result column="table_name" jdbcType="VARCHAR" property="tableName"/>
<result column="is_buy_coupon" jdbcType="VARCHAR" property="isBuyCoupon"/>
</resultMap>
<sql id="Base_Column_List">
id, order_no, settlement_amount, pack_fee, origin_amount, product_amount, amount,
@@ -53,7 +54,7 @@
discount_amount, table_id, small_change, send_type, order_type, product_type, status,
billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score,
user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group,
updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,remark,master_id,`table_name`
updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,remark,master_id,`table_name`,is_buy_coupon
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@@ -80,7 +81,7 @@
deduct_score, user_coupon_id, user_coupon_amount,
refund_able, paid_time, is_effect,
is_group, updated_at, system_time,
created_at, is_accepted, pay_order_no,trade_day,source,remark,master_id,table_name
created_at, is_accepted, pay_order_no,trade_day,source,remark,master_id,table_name,is_buy_coupon
)
values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
#{packFee,jdbcType=DECIMAL}, #{originAmount,jdbcType=DECIMAL}, #{productAmount,jdbcType=DECIMAL},
@@ -95,7 +96,8 @@
#{refundAble,jdbcType=TINYINT}, #{paidTime,jdbcType=BIGINT}, #{isEffect,jdbcType=TINYINT},
#{isGroup,jdbcType=TINYINT}, #{updatedAt,jdbcType=BIGINT}, #{systemTime,jdbcType=BIGINT},
#{createdAt,jdbcType=BIGINT}, #{isAccepted,jdbcType=TINYINT}, #{payOrderNo,jdbcType=VARCHAR},
#{tradeDay,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{masterId,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR}
#{tradeDay,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR},
#{masterId,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR}, #{isBuyCoupon,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo"
@@ -219,10 +221,16 @@
<if test="payOrderNo != null">
pay_order_no,
</if>
<if test="isBuyCoupon != null">
is_buy_coupon,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="isBuyCoupon != null">
#{isBuyCoupon,jdbcType=INTEGER},
</if>
<if test="orderNo != null">
#{orderNo,jdbcType=VARCHAR},
@@ -463,6 +471,9 @@
<if test="tradeDay != null">
trade_day = #{tradeDay,jdbcType=VARCHAR},
</if>
<if test="isBuyCoupon != null">
is_buy_coupon = #{isBuyCoupon,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
@@ -505,6 +516,7 @@
system_time = #{systemTime,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=BIGINT},
is_accepted = #{isAccepted,jdbcType=TINYINT},
is_buy_coupon = #{isBuyCoupon,jdbcType=TINYINT},
pay_order_no = #{payOrderNo,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>

View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbParamsMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbParams">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="integral_ratio" jdbcType="DECIMAL" property="integralRatio" />
<result column="trade_ratio" jdbcType="DECIMAL" property="tradeRatio" />
</resultMap>
<sql id="Base_Column_List">
id, integral_ratio, trade_ratio
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_params
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_params
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbParams">
insert into tb_params (id, integral_ratio, trade_ratio
)
values (#{id,jdbcType=INTEGER}, #{integralRatio,jdbcType=DECIMAL}, #{tradeRatio,jdbcType=DECIMAL}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbParams">
insert into tb_params
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="integralRatio != null">
integral_ratio,
</if>
<if test="tradeRatio != null">
trade_ratio,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="integralRatio != null">
#{integralRatio,jdbcType=DECIMAL},
</if>
<if test="tradeRatio != null">
#{tradeRatio,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbParams">
update tb_params
<set>
<if test="integralRatio != null">
integral_ratio = #{integralRatio,jdbcType=DECIMAL},
</if>
<if test="tradeRatio != null">
trade_ratio = #{tradeRatio,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbParams">
update tb_params
set integral_ratio = #{integralRatio,jdbcType=DECIMAL},
trade_ratio = #{tradeRatio,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@@ -370,4 +370,10 @@
<select id="selectByUserId" resultMap="BaseResultMap">
select * from tb_shop_user where user_id=#{userId}
</select>
<select id="selectByOpenId" resultType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
select * from tb_shop_user where mini_open_id = #{openId}
</select>
<select id="selectParams" resultType="com.chaozhanggui.system.cashierservice.entity.TbParams">
select * from tb_params where id = 1
</select>
</mapper>

View File

@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbSystemCouponsMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="coupons_price" jdbcType="DECIMAL" property="couponsPrice" />
<result column="coupons_amount" jdbcType="DECIMAL" property="couponsAmount" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
</resultMap>
<sql id="Base_Column_List">
id, name, coupons_price, coupons_amount, status, create_time, update_time, end_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_system_coupons
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultType="com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons">
select * from tb_system_coupons where status = '0'
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_system_coupons
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons">
insert into tb_system_coupons (id, name, coupons_price,
coupons_amount, status, create_time,
update_time, end_time)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{couponsPrice,jdbcType=DECIMAL},
#{couponsAmount,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons">
insert into tb_system_coupons
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
name,
</if>
<if test="couponsPrice != null">
coupons_price,
</if>
<if test="couponsAmount != null">
coupons_amount,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="endTime != null">
end_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="couponsPrice != null">
#{couponsPrice,jdbcType=DECIMAL},
</if>
<if test="couponsAmount != null">
#{couponsAmount,jdbcType=DECIMAL},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
#{endTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons">
update tb_system_coupons
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="couponsPrice != null">
coupons_price = #{couponsPrice,jdbcType=DECIMAL},
</if>
<if test="couponsAmount != null">
coupons_amount = #{couponsAmount,jdbcType=DECIMAL},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons">
update tb_system_coupons
set name = #{name,jdbcType=VARCHAR},
coupons_price = #{couponsPrice,jdbcType=DECIMAL},
coupons_amount = #{couponsAmount,jdbcType=DECIMAL},
status = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
end_time = #{endTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbUserCouponsMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="coupons_price" jdbcType="DECIMAL" property="couponsPrice" />
<result column="coupons_amount" jdbcType="DECIMAL" property="couponsAmount" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
</resultMap>
<sql id="Base_Column_List">
id, user_id, coupons_price, coupons_amount, status, create_time, update_time, end_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_user_coupons
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByUserId" resultType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
select * from tb_user_coupons where user_id = #{userId}
<if test="status != null and status != ''">
and status = #{status}
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_user_coupons
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons" useGeneratedKeys="true" keyProperty="id">
insert into tb_user_coupons (id, user_id, coupons_price,
coupons_amount, status, create_time,
update_time, end_time)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{couponsPrice,jdbcType=DECIMAL},
#{couponsAmount,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
insert into tb_user_coupons
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="couponsPrice != null">
coupons_price,
</if>
<if test="couponsAmount != null">
coupons_amount,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="endTime != null">
end_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="couponsPrice != null">
#{couponsPrice,jdbcType=DECIMAL},
</if>
<if test="couponsAmount != null">
#{couponsAmount,jdbcType=DECIMAL},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
#{endTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
update tb_user_coupons
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="couponsPrice != null">
coupons_price = #{couponsPrice,jdbcType=DECIMAL},
</if>
<if test="couponsAmount != null">
coupons_amount = #{couponsAmount,jdbcType=DECIMAL},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
update tb_user_coupons
set user_id = #{userId,jdbcType=VARCHAR},
coupons_price = #{couponsPrice,jdbcType=DECIMAL},
coupons_amount = #{couponsAmount,jdbcType=DECIMAL},
status = #{status,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
end_time = #{endTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbWiningUserMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbWiningUser">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="order_no" jdbcType="VARCHAR" property="orderNo" />
<result column="order_amount" jdbcType="DECIMAL" property="orderAmount" />
<result column="is_user" jdbcType="VARCHAR" property="isUser" />
<result column="trade_day" jdbcType="VARCHAR" property="tradeDay" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id, user_name, order_no, order_amount, is_user, create_time,trade_day
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_wining_user
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAllByTrade" resultType="com.chaozhanggui.system.cashierservice.entity.TbWiningUser">
select * from tb_wining_user where trade_day = #{day}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_wining_user
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningUser">
insert into tb_wining_user (id, user_name, order_no,
order_amount, is_user, create_time
)
values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR},
#{orderAmount,jdbcType=DECIMAL}, #{isUser,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningUser">
insert into tb_wining_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userName != null">
user_name,
</if>
<if test="orderNo != null">
order_no,
</if>
<if test="orderAmount != null">
order_amount,
</if>
<if test="isUser != null">
is_user,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userName != null">
#{userName,jdbcType=VARCHAR},
</if>
<if test="orderNo != null">
#{orderNo,jdbcType=VARCHAR},
</if>
<if test="orderAmount != null">
#{orderAmount,jdbcType=DECIMAL},
</if>
<if test="isUser != null">
#{isUser,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningUser">
update tb_wining_user
<set>
<if test="userName != null">
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if test="orderNo != null">
order_no = #{orderNo,jdbcType=VARCHAR},
</if>
<if test="orderAmount != null">
order_amount = #{orderAmount,jdbcType=DECIMAL},
</if>
<if test="isUser != null">
is_user = #{isUser,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningUser">
update tb_wining_user
set user_name = #{userName,jdbcType=VARCHAR},
order_no = #{orderNo,jdbcType=VARCHAR},
order_amount = #{orderAmount,jdbcType=DECIMAL},
is_user = #{isUser,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>