优惠券+异常全局处理
This commit is contained in:
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@@ -51,7 +52,7 @@ public class OrderController {
|
||||
orderService.testMessage(tableId,message);
|
||||
}
|
||||
@GetMapping("/tradeIntegral")
|
||||
private Result tradeIntegral(@RequestParam("userId") String userId, @RequestParam("id") String id) throws IOException {
|
||||
private Result tradeIntegral(@RequestParam("userId") String userId, @RequestParam("id") String id) throws IOException, ParseException {
|
||||
return orderService.tradeIntegral(userId,id);
|
||||
}
|
||||
// @GetMapping("/我的积分")
|
||||
@@ -65,13 +66,21 @@ public class OrderController {
|
||||
return orderService.mineCoupons(userId,status,page,size);
|
||||
}
|
||||
@GetMapping("/findCoupons")
|
||||
private Result findCoupons(@RequestHeader String token,
|
||||
private Result findCoupons(@RequestHeader String token,@RequestParam String type,
|
||||
@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);
|
||||
return orderService.findCoupons(type,page,size);
|
||||
}
|
||||
@GetMapping("/findWiningUser")
|
||||
private Result findWiningUser(){
|
||||
return orderService.findWiningUser();
|
||||
}
|
||||
@GetMapping("/getYhqPara")
|
||||
private Result getYhqPara(){
|
||||
return orderService.getYhqPara();
|
||||
}
|
||||
@GetMapping("/testPay")
|
||||
private Result testPay(@RequestParam Integer orderId){
|
||||
return orderService.testPay(orderId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ 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.IntegralFlowVo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.OrderVo;
|
||||
import com.chaozhanggui.system.cashierservice.service.LoginService;
|
||||
@@ -76,4 +77,10 @@ public class UserContoller {
|
||||
String userSign = jsonObject.getString("userSign");
|
||||
return userService.modityIntegral(integralVo,userSign);
|
||||
}
|
||||
@GetMapping("/userIntegral")
|
||||
public JSONObject userIntegral(@RequestHeader String token,@RequestBody IntegralFlowVo integralFlowVo ) throws Exception {
|
||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||
String userSign = jsonObject.getString("userSign");
|
||||
return userService.userIntegral(integralFlowVo,userSign);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@@ -32,5 +33,5 @@ public interface TbOrderInfoMapper {
|
||||
@Param("size")Integer size, @Param("status") String status);
|
||||
|
||||
|
||||
|
||||
List<TbOrderInfo> selectByTradeDay(@Param("day") String day,@Param("minPrice") BigDecimal minPrice,@Param("maxPrice") BigDecimal maxPrice);
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbReleaseFlowMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
@@ -14,4 +17,6 @@ public interface TbReleaseFlowMapper {
|
||||
int updateByPrimaryKeySelective(TbReleaseFlow record);
|
||||
|
||||
int updateByPrimaryKey(TbReleaseFlow record);
|
||||
|
||||
List<TbReleaseFlow> selectByUserId(@Param("userId") String userId);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,5 +18,5 @@ public interface TbSystemCouponsMapper {
|
||||
|
||||
int updateByPrimaryKey(TbSystemCoupons record);
|
||||
|
||||
List<TbSystemCoupons> selectAll();
|
||||
List<TbSystemCoupons> selectAll(@Param("type") String type);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbWiningParams;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbWiningParamsMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(TbWiningParams record);
|
||||
|
||||
int insertSelective(TbWiningParams record);
|
||||
|
||||
TbWiningParams selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(TbWiningParams record);
|
||||
|
||||
int updateByPrimaryKey(TbWiningParams record);
|
||||
|
||||
List<TbWiningParams> selectAll();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbYhqParams;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbYhqParamsMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(TbYhqParams record);
|
||||
|
||||
int insertSelective(TbYhqParams record);
|
||||
|
||||
TbYhqParams selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(TbYhqParams record);
|
||||
|
||||
int updateByPrimaryKey(TbYhqParams record);
|
||||
|
||||
List<TbYhqParams> selectAll();
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Data
|
||||
public class TbShopInfo implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
@@ -95,366 +99,5 @@ public class TbShopInfo implements Serializable {
|
||||
* 商家二维码
|
||||
*/
|
||||
private String shopQrcode;
|
||||
|
||||
public String getShopQrcode() {
|
||||
return shopQrcode;
|
||||
}
|
||||
|
||||
public void setShopQrcode(String shopQrcode) {
|
||||
this.shopQrcode = shopQrcode;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account == null ? null : account.trim();
|
||||
}
|
||||
|
||||
public String getShopCode() {
|
||||
return shopCode;
|
||||
}
|
||||
|
||||
public void setShopCode(String shopCode) {
|
||||
this.shopCode = shopCode == null ? null : shopCode.trim();
|
||||
}
|
||||
|
||||
public String getSubTitle() {
|
||||
return subTitle;
|
||||
}
|
||||
|
||||
public void setSubTitle(String subTitle) {
|
||||
this.subTitle = subTitle == null ? null : subTitle.trim();
|
||||
}
|
||||
|
||||
public String getMerchantId() {
|
||||
return merchantId;
|
||||
}
|
||||
|
||||
public void setMerchantId(String merchantId) {
|
||||
this.merchantId = merchantId == null ? null : merchantId.trim();
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName == null ? null : shopName.trim();
|
||||
}
|
||||
|
||||
public String getChainName() {
|
||||
return chainName;
|
||||
}
|
||||
|
||||
public void setChainName(String chainName) {
|
||||
this.chainName = chainName == null ? null : chainName.trim();
|
||||
}
|
||||
|
||||
public String getBackImg() {
|
||||
return backImg;
|
||||
}
|
||||
|
||||
public void setBackImg(String backImg) {
|
||||
this.backImg = backImg == null ? null : backImg.trim();
|
||||
}
|
||||
|
||||
public String getFrontImg() {
|
||||
return frontImg;
|
||||
}
|
||||
|
||||
public void setFrontImg(String frontImg) {
|
||||
this.frontImg = frontImg == null ? null : frontImg.trim();
|
||||
}
|
||||
|
||||
public String getContactName() {
|
||||
return contactName;
|
||||
}
|
||||
|
||||
public void setContactName(String contactName) {
|
||||
this.contactName = contactName == null ? null : contactName.trim();
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone == null ? null : phone.trim();
|
||||
}
|
||||
|
||||
public String getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
public void setLogo(String logo) {
|
||||
this.logo = logo == null ? null : logo.trim();
|
||||
}
|
||||
|
||||
public Byte getIsDeposit() {
|
||||
return isDeposit;
|
||||
}
|
||||
|
||||
public void setIsDeposit(Byte isDeposit) {
|
||||
this.isDeposit = isDeposit;
|
||||
}
|
||||
|
||||
public Byte getIsSupply() {
|
||||
return isSupply;
|
||||
}
|
||||
|
||||
public void setIsSupply(Byte isSupply) {
|
||||
this.isSupply = isSupply;
|
||||
}
|
||||
|
||||
public String getCoverImg() {
|
||||
return coverImg;
|
||||
}
|
||||
|
||||
public void setCoverImg(String coverImg) {
|
||||
this.coverImg = coverImg == null ? null : coverImg.trim();
|
||||
}
|
||||
|
||||
public String getShareImg() {
|
||||
return shareImg;
|
||||
}
|
||||
|
||||
public void setShareImg(String shareImg) {
|
||||
this.shareImg = shareImg == null ? null : shareImg.trim();
|
||||
}
|
||||
|
||||
public String getDetail() {
|
||||
return detail;
|
||||
}
|
||||
|
||||
public void setDetail(String detail) {
|
||||
this.detail = detail == null ? null : detail.trim();
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(String lat) {
|
||||
this.lat = lat == null ? null : lat.trim();
|
||||
}
|
||||
|
||||
public String getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public void setLng(String lng) {
|
||||
this.lng = lng == null ? null : lng.trim();
|
||||
}
|
||||
|
||||
public String getMchId() {
|
||||
return mchId;
|
||||
}
|
||||
|
||||
public void setMchId(String mchId) {
|
||||
this.mchId = mchId == null ? null : mchId.trim();
|
||||
}
|
||||
|
||||
public String getRegisterType() {
|
||||
return registerType;
|
||||
}
|
||||
|
||||
public void setRegisterType(String registerType) {
|
||||
this.registerType = registerType == null ? null : registerType.trim();
|
||||
}
|
||||
|
||||
public Byte getIsWxMaIndependent() {
|
||||
return isWxMaIndependent;
|
||||
}
|
||||
|
||||
public void setIsWxMaIndependent(Byte isWxMaIndependent) {
|
||||
this.isWxMaIndependent = isWxMaIndependent;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address == null ? null : address.trim();
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city == null ? null : city.trim();
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type == null ? null : type.trim();
|
||||
}
|
||||
|
||||
public String getIndustry() {
|
||||
return industry;
|
||||
}
|
||||
|
||||
public void setIndustry(String industry) {
|
||||
this.industry = industry == null ? null : industry.trim();
|
||||
}
|
||||
|
||||
public String getIndustryName() {
|
||||
return industryName;
|
||||
}
|
||||
|
||||
public void setIndustryName(String industryName) {
|
||||
this.industryName = industryName == null ? null : industryName.trim();
|
||||
}
|
||||
|
||||
public String getBusinessTime() {
|
||||
return businessTime;
|
||||
}
|
||||
|
||||
public void setBusinessTime(String businessTime) {
|
||||
this.businessTime = businessTime == null ? null : businessTime.trim();
|
||||
}
|
||||
|
||||
public String getPostTime() {
|
||||
return postTime;
|
||||
}
|
||||
|
||||
public void setPostTime(String postTime) {
|
||||
this.postTime = postTime == null ? null : postTime.trim();
|
||||
}
|
||||
|
||||
public BigDecimal getPostAmountLine() {
|
||||
return postAmountLine;
|
||||
}
|
||||
|
||||
public void setPostAmountLine(BigDecimal postAmountLine) {
|
||||
this.postAmountLine = postAmountLine;
|
||||
}
|
||||
|
||||
public Byte getOnSale() {
|
||||
return onSale;
|
||||
}
|
||||
|
||||
public void setOnSale(Byte onSale) {
|
||||
this.onSale = onSale;
|
||||
}
|
||||
|
||||
public Byte getSettleType() {
|
||||
return settleType;
|
||||
}
|
||||
|
||||
public void setSettleType(Byte settleType) {
|
||||
this.settleType = settleType;
|
||||
}
|
||||
|
||||
public String getSettleTime() {
|
||||
return settleTime;
|
||||
}
|
||||
|
||||
public void setSettleTime(String settleTime) {
|
||||
this.settleTime = settleTime == null ? null : settleTime.trim();
|
||||
}
|
||||
|
||||
public Integer getEnterAt() {
|
||||
return enterAt;
|
||||
}
|
||||
|
||||
public void setEnterAt(Integer enterAt) {
|
||||
this.enterAt = enterAt;
|
||||
}
|
||||
|
||||
public Long getExpireAt() {
|
||||
return expireAt;
|
||||
}
|
||||
|
||||
public void setExpireAt(Long expireAt) {
|
||||
this.expireAt = expireAt;
|
||||
}
|
||||
|
||||
public Byte getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Byte status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Float getAverage() {
|
||||
return average;
|
||||
}
|
||||
|
||||
public void setAverage(Float average) {
|
||||
this.average = average;
|
||||
}
|
||||
|
||||
public Integer getOrderWaitPayMinute() {
|
||||
return orderWaitPayMinute;
|
||||
}
|
||||
|
||||
public void setOrderWaitPayMinute(Integer orderWaitPayMinute) {
|
||||
this.orderWaitPayMinute = orderWaitPayMinute;
|
||||
}
|
||||
|
||||
public Integer getSupportDeviceNumber() {
|
||||
return supportDeviceNumber;
|
||||
}
|
||||
|
||||
public void setSupportDeviceNumber(Integer supportDeviceNumber) {
|
||||
this.supportDeviceNumber = supportDeviceNumber;
|
||||
}
|
||||
|
||||
public Byte getDistributeLevel() {
|
||||
return distributeLevel;
|
||||
}
|
||||
|
||||
public void setDistributeLevel(Byte distributeLevel) {
|
||||
this.distributeLevel = distributeLevel;
|
||||
}
|
||||
|
||||
public Long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Long getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Long updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public String getProxyId() {
|
||||
return proxyId;
|
||||
}
|
||||
|
||||
public void setProxyId(String proxyId) {
|
||||
this.proxyId = proxyId == null ? null : proxyId.trim();
|
||||
}
|
||||
|
||||
public String getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setView(String view) {
|
||||
this.view = view == null ? null : view.trim();
|
||||
}
|
||||
private String isOpenYhq;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public class TbSystemCoupons implements Serializable {
|
||||
private BigDecimal couponsAmount;
|
||||
|
||||
private String status;
|
||||
private String typeName;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class TbWiningParams implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private BigDecimal minPrice;
|
||||
|
||||
private BigDecimal maxPrice;
|
||||
|
||||
private Integer winingNum;
|
||||
|
||||
private Integer winingUserNum;
|
||||
private String status;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -17,9 +17,38 @@ public class TbWiningUser implements Serializable {
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
private String isUser;
|
||||
private String tradeDay;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private String isRefund;
|
||||
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
private String refundNo;
|
||||
|
||||
private String refundPayType;
|
||||
|
||||
private String tradeDay;
|
||||
|
||||
private Date refundTime;
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public TbWiningUser(){
|
||||
super();
|
||||
}
|
||||
public TbWiningUser(String userName,String orderNo,BigDecimal orderAmount,
|
||||
String isUser,String tradeDay){
|
||||
this.createTime = new Date();
|
||||
this.userName = userName;
|
||||
this.orderNo = orderNo;
|
||||
this.orderAmount = orderAmount;
|
||||
this.isUser = isUser;
|
||||
this.tradeDay = tradeDay;
|
||||
this.isRefund = "false";
|
||||
this.refundAmount = BigDecimal.ZERO;
|
||||
this.refundPayType = "WX";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class TbYhqParams implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private BigDecimal minPrice;
|
||||
|
||||
private BigDecimal maxPrice;
|
||||
|
||||
private String status;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
}
|
||||
|
||||
public BigDecimal getMinPrice() {
|
||||
return minPrice;
|
||||
}
|
||||
|
||||
public void setMinPrice(BigDecimal minPrice) {
|
||||
this.minPrice = minPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getMaxPrice() {
|
||||
return maxPrice;
|
||||
}
|
||||
|
||||
public void setMaxPrice(BigDecimal maxPrice) {
|
||||
this.maxPrice = maxPrice;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status == null ? null : status.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class IntegralFlowVo {
|
||||
private String openId;
|
||||
private Integer page;
|
||||
private Integer pageSize;
|
||||
private String sign;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.chaozhanggui.system.cashierservice.exception;
|
||||
|
||||
|
||||
public enum DefaultError implements IError {
|
||||
/**
|
||||
* 系统内部错误
|
||||
*/
|
||||
SYSTEM_INTERNAL_ERROR("0000", "系统错误"),
|
||||
/**
|
||||
* 无效参数
|
||||
*/
|
||||
INVALID_PARAMETER("0001", "参数验证失败"),
|
||||
/**
|
||||
* 服务不存在
|
||||
*/
|
||||
SERVICE_NOT_FOUND("0002", "服务不存在"),
|
||||
/**
|
||||
* 参数不全
|
||||
*/
|
||||
PARAMETER_REQUIRED("0003", "参数不全"),
|
||||
/**
|
||||
* 参数过长
|
||||
*/
|
||||
PARAMETER_MAX_LENGTH("0004", "参数过长"),
|
||||
/**
|
||||
* 参数过短
|
||||
*/
|
||||
PARAMETER_MIN_LENGTH("0005", "参数过短"),
|
||||
/**
|
||||
* 认证失败
|
||||
*/
|
||||
AUTHENTICATION_ERROR("0006", "认证失败"),
|
||||
/**
|
||||
* 认证动作失败
|
||||
*/
|
||||
AUTHENTICATION_OPTION_ERROR("0007", "认证失败"),
|
||||
/**
|
||||
* 请求方法出错
|
||||
*/
|
||||
METHOD_NOT_SUPPORTED("0008", "请求方法出错"),
|
||||
/**
|
||||
* 不支持的content类型
|
||||
*/
|
||||
CONTENT_TYPE_NOT_SUPPORT("0009", "不支持的content类型"),
|
||||
/**
|
||||
* json格式化出错
|
||||
*/
|
||||
JSON_FORMAT_ERROR("0010", "json格式化出错"),
|
||||
/**
|
||||
* 远程调用出错
|
||||
*/
|
||||
CALL_REMOTE_ERROR("0011", "远程调用出错"),
|
||||
/**
|
||||
* 服务运行SQLException异常
|
||||
*/
|
||||
SQL_EXCEPTION("0012", "服务运行SQL异常"),
|
||||
/**
|
||||
* 客户端异常 给调用者 app,移动端调用
|
||||
*/
|
||||
CLIENT_EXCEPTION("0013", "客户端异常"),
|
||||
/**
|
||||
* 服务端异常, 微服务服务端产生的异常
|
||||
*/
|
||||
SERVER_EXCEPTION("0014", "服务端异常"),
|
||||
/**
|
||||
* 授权失败 禁止访问
|
||||
*/
|
||||
ACCESS_DENIED("0015", "没有访问权限"),
|
||||
/**
|
||||
* 演示环境 没有权限访问
|
||||
*/
|
||||
SHOW_AUTH_CONTROL("0016", "演示环境,没有权限访问"),
|
||||
/**
|
||||
* 业务异常
|
||||
*/
|
||||
BUSINESS_ERROR("0017", "业务异常"),
|
||||
|
||||
NO_USER("0018","用户不存在");
|
||||
|
||||
String errorCode;
|
||||
String errorMessage;
|
||||
private static final String NS = "SYS";
|
||||
|
||||
DefaultError(String errorCode, String errorMessage) {
|
||||
this.errorCode = errorCode;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameSpace() {
|
||||
return NS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorCode() {
|
||||
return NS + "." + this.errorCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage() {
|
||||
return this.errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package com.chaozhanggui.system.cashierservice.exception;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.UnexpectedTypeException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ControllerAdvice
|
||||
@ResponseBody
|
||||
public class DefaultExceptionAdvice {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultExceptionAdvice.class);
|
||||
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ExceptionHandler({HttpMessageNotReadableException.class, })
|
||||
public ResponseEntity handleHttpMessageNotReadableException(HttpMessageNotReadableException e) {
|
||||
LOGGER.error("参数解析失败", e);
|
||||
Result response = Result.failure(DefaultError.INVALID_PARAMETER);
|
||||
response.setMsg(e.getMessage());
|
||||
return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
@ExceptionHandler({HttpRequestMethodNotSupportedException.class})
|
||||
public ResponseEntity handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
|
||||
LOGGER.error("不支持当前请求方法", e);
|
||||
Result response = Result.failure(DefaultError.METHOD_NOT_SUPPORTED);
|
||||
response.setMsg(e.getMessage());
|
||||
return new ResponseEntity<>(response, HttpStatus.METHOD_NOT_ALLOWED);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE)
|
||||
@ExceptionHandler({HttpMediaTypeNotSupportedException.class})
|
||||
public ResponseEntity handleHttpMediaTypeNotSupportedException(HttpMediaTypeNotSupportedException e) {
|
||||
LOGGER.error("不支持当前媒体类型", e);
|
||||
Result response = Result.failure(DefaultError.CONTENT_TYPE_NOT_SUPPORT);
|
||||
response.setMsg(e.getMessage());
|
||||
return new ResponseEntity<>(response, HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler({SQLException.class})
|
||||
public ResponseEntity handleSQLException(SQLException e) {
|
||||
LOGGER.error("服务运行SQLException异常", e);
|
||||
Result response = Result.failure(DefaultError.SQL_EXCEPTION);
|
||||
response.setMsg(e.getMessage());
|
||||
return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有异常统一处理
|
||||
*
|
||||
* @return ResponseEntity
|
||||
*/
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity handleException(Exception ex) {
|
||||
LOGGER.error("未知异常", ex);
|
||||
IError error;
|
||||
String extMessage = null;
|
||||
if (ex instanceof BindException) {
|
||||
error = DefaultError.INVALID_PARAMETER;
|
||||
List<ObjectError> errors = ((BindException) ex).getAllErrors();
|
||||
if (errors.size() != 0) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (ObjectError objectError : errors) {
|
||||
msg.append("Field error in object '").append(objectError.getObjectName()).append(" ");
|
||||
if (objectError instanceof FieldError) {
|
||||
msg.append("on field ").append(((FieldError) objectError).getField()).append(" ");
|
||||
}
|
||||
msg.append(objectError.getDefaultMessage()).append(" ");
|
||||
}
|
||||
extMessage = msg.toString();
|
||||
}
|
||||
} else if (ex instanceof MissingServletRequestParameterException) {
|
||||
error = DefaultError.INVALID_PARAMETER;
|
||||
extMessage = ex.getMessage();
|
||||
} else if (ex instanceof ConstraintViolationException) {
|
||||
error = DefaultError.INVALID_PARAMETER;
|
||||
Set<ConstraintViolation<?>> violations = ((ConstraintViolationException) ex).getConstraintViolations();
|
||||
final StringBuilder msg = new StringBuilder();
|
||||
for (ConstraintViolation<?> constraintViolation : violations) {
|
||||
msg.append(constraintViolation.getPropertyPath()).append(":").append(constraintViolation.getMessage()).append("\n");
|
||||
}
|
||||
extMessage = msg.toString();
|
||||
} else if (ex instanceof HttpMediaTypeNotSupportedException) {
|
||||
error = DefaultError.CONTENT_TYPE_NOT_SUPPORT;
|
||||
extMessage = ex.getMessage();
|
||||
} else if (ex instanceof HttpMessageNotReadableException) {
|
||||
error = DefaultError.INVALID_PARAMETER;
|
||||
extMessage = ex.getMessage();
|
||||
} else if (ex instanceof MethodArgumentNotValidException) {
|
||||
error = DefaultError.INVALID_PARAMETER;
|
||||
final BindingResult result = ((MethodArgumentNotValidException) ex).getBindingResult();
|
||||
if (result.hasErrors()) {
|
||||
extMessage = result.getAllErrors().get(0).getDefaultMessage();
|
||||
} else {
|
||||
extMessage = ex.getMessage();
|
||||
}
|
||||
} else if (ex instanceof HttpRequestMethodNotSupportedException) {
|
||||
error = DefaultError.METHOD_NOT_SUPPORTED;
|
||||
extMessage = ex.getMessage();
|
||||
} else if (ex instanceof UnexpectedTypeException) {
|
||||
error = DefaultError.INVALID_PARAMETER;
|
||||
extMessage = ex.getMessage();
|
||||
} else if (ex instanceof NoHandlerFoundException) {
|
||||
error = DefaultError.SERVICE_NOT_FOUND;
|
||||
extMessage = ex.getMessage();
|
||||
} else {
|
||||
error = DefaultError.SYSTEM_INTERNAL_ERROR;
|
||||
extMessage = ex.getMessage();
|
||||
}
|
||||
|
||||
|
||||
Result response = Result.failure(error);
|
||||
response.setMsg(extMessage);
|
||||
return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* BusinessException 业务异常处理
|
||||
*
|
||||
* @return ResponseEntity
|
||||
*/
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ExceptionHandler(MsgException.class)
|
||||
public ResponseEntity handleException(MsgException e) {
|
||||
LOGGER.error("业务异常", e);
|
||||
Result response = Result.failure(DefaultError.BUSINESS_ERROR);
|
||||
response.setMsg(e.getMessage());
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.chaozhanggui.system.cashierservice.exception;
|
||||
|
||||
public interface IError {
|
||||
|
||||
/**
|
||||
* 获取nameSpace
|
||||
*
|
||||
* @return nameSpace
|
||||
*/
|
||||
String getNameSpace();
|
||||
|
||||
/**
|
||||
* 获取错误码
|
||||
|
||||
* @return 错误码
|
||||
*/
|
||||
String getErrorCode();
|
||||
|
||||
/**
|
||||
* 获取错误信息
|
||||
|
||||
* @return 错误信息
|
||||
*/
|
||||
String getErrorMessage();
|
||||
|
||||
/**
|
||||
* 设置错误信息
|
||||
*
|
||||
* @param errorMessage 错误信息
|
||||
*/
|
||||
void setErrorMessage(String errorMessage);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RabbitListener(queues = {RabbitConstants.CART_QUEUE_PUT})
|
||||
//@RabbitListener(queues = {RabbitConstants.CART_QUEUE_PUT})
|
||||
@Service
|
||||
public class CartConsumer {
|
||||
|
||||
@@ -39,6 +39,7 @@ public class CartConsumer {
|
||||
@Autowired
|
||||
private CartService cartService;
|
||||
@RabbitHandler
|
||||
@RabbitListener(queues = {"${queue}"})
|
||||
public void listener(String message) {
|
||||
try {
|
||||
JSONObject jsonObject = JSON.parseObject(message);
|
||||
|
||||
@@ -27,7 +27,8 @@ public class RabbitConfig {
|
||||
|
||||
@Value("${spring.rabbitmq.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${prod}")
|
||||
private String prod;
|
||||
|
||||
|
||||
@Bean
|
||||
@@ -49,17 +50,17 @@ public class RabbitConfig {
|
||||
}
|
||||
@Bean
|
||||
public DirectExchange defaultExchange_Register() {
|
||||
return new DirectExchange(RabbitConstants.CART_PUT);
|
||||
return new DirectExchange(RabbitConstants.CART_PUT+prod);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue queuePut_Register() {
|
||||
return new Queue(RabbitConstants.CART_QUEUE_PUT, true); //队列持久
|
||||
return new Queue(RabbitConstants.CART_QUEUE_PUT+prod, true); //队列持久
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingPut_Register() {
|
||||
return BindingBuilder.bind(queuePut_Register()).to(defaultExchange_Register()).with(RabbitConstants.CART_ROUTINGKEY_PUT);
|
||||
return BindingBuilder.bind(queuePut_Register()).to(defaultExchange_Register()).with(RabbitConstants.CART_ROUTINGKEY_PUT+prod);
|
||||
}
|
||||
@Bean
|
||||
public DirectExchange defaultIntegral() {
|
||||
|
||||
@@ -32,10 +32,10 @@ public interface RabbitConstants {
|
||||
|
||||
|
||||
|
||||
public static final String INTEGRAL_PUT="integral_put";
|
||||
public static final String INTEGRAL_PUT="integral_put1";
|
||||
|
||||
public static final String INTEGRAL_QUEUE_PUT = "integral_queue_put";
|
||||
public static final String INTEGRAL_QUEUE_PUT = "integral_queue_put1";
|
||||
|
||||
|
||||
public static final String INTEGRAL_ROUTINGKEY_PUT = "integral_routingkey_put";
|
||||
public static final String INTEGRAL_ROUTINGKEY_PUT = "integral_routingkey_put1";
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -16,7 +17,8 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Value("${prod}")
|
||||
private String prod;
|
||||
@Autowired
|
||||
public RabbitProducer(RabbitTemplate rabbitTemplate) {
|
||||
this.rabbitTemplate = rabbitTemplate;
|
||||
@@ -25,7 +27,7 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
|
||||
|
||||
public void putCart(String content) {
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CART_PUT, RabbitConstants.CART_ROUTINGKEY_PUT, content, correlationId);
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CART_PUT+prod, RabbitConstants.CART_ROUTINGKEY_PUT+prod, content, correlationId);
|
||||
}
|
||||
public void putOrderCollect(String content) {
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
@@ -38,7 +40,7 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
|
||||
}
|
||||
public void printCoupons(String content){
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.INTEGRAL_QUEUE_PUT, RabbitConstants.INTEGRAL_ROUTINGKEY_PUT, content, correlationId);
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.INTEGRAL_PUT, RabbitConstants.INTEGRAL_ROUTINGKEY_PUT, content, correlationId);
|
||||
}
|
||||
@Override
|
||||
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||||
|
||||
@@ -213,7 +213,7 @@ public class CartService {
|
||||
BigDecimal packAMount = BigDecimal.ZERO;
|
||||
BigDecimal originAmount = BigDecimal.ZERO;
|
||||
BigDecimal saleAmount = BigDecimal.ZERO;
|
||||
String couponId = "";
|
||||
String couponId = jsonObject.getString("couponsId");
|
||||
BigDecimal couponAmount = BigDecimal.ZERO;
|
||||
Map<Integer, TbProductSku> skuMap = new HashMap<>();
|
||||
List<TbOrderDetail> orderDetails = new ArrayList<>();
|
||||
@@ -270,12 +270,12 @@ public class CartService {
|
||||
//生成订单
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId);
|
||||
String isBuyYhq = "false";
|
||||
if (jsonObject.containsKey("isYhq")){
|
||||
if (jsonObject.containsKey("isYhq") && jsonObject.getString("isYhq").equals("1")) {
|
||||
//1:购买优惠券,0:自己持有优惠券
|
||||
Integer couponsId = jsonObject.getInteger("couponsId");
|
||||
if (jsonObject.getString("isBuyYhq").equals("1")){
|
||||
if (jsonObject.getString("isBuyYhq").equals("1")) {
|
||||
TbSystemCoupons systemCoupons = systemCouponsMapper.selectByPrimaryKey(couponsId);
|
||||
if (Objects.isNull(systemCoupons) || !systemCoupons.getStatus().equals("0")){
|
||||
if (Objects.isNull(systemCoupons) || !systemCoupons.getStatus().equals("0")) {
|
||||
log.info("开始处理订单");
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
@@ -286,7 +286,7 @@ public class CartService {
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
if (N.gt(systemCoupons.getCouponsAmount(),totalAmount)){
|
||||
if (N.gt(systemCoupons.getCouponsAmount(), totalAmount)) {
|
||||
log.info("开始处理订单");
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
@@ -299,21 +299,22 @@ public class CartService {
|
||||
}
|
||||
totalAmount = totalAmount.add(systemCoupons.getCouponsPrice()).subtract(systemCoupons.getCouponsAmount());
|
||||
originAmount = originAmount.add(systemCoupons.getCouponsPrice());
|
||||
couponAmount = systemCoupons.getCouponsAmount();
|
||||
systemCoupons.setStatus("1");
|
||||
systemCouponsMapper.updateByPrimaryKeySelective(systemCoupons);
|
||||
TbUserCoupons userCoupons = new TbUserCoupons();
|
||||
userCoupons.setEndTime(DateUtils.getNewDate(new Date(),3,systemCoupons.getDayNum()));
|
||||
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()+"";
|
||||
couponId = userCoupons.getId() + "";
|
||||
couponAmount = userCoupons.getCouponsAmount();
|
||||
}else {
|
||||
} else {
|
||||
TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(couponsId);
|
||||
if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0")){
|
||||
if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0")) {
|
||||
log.info("开始处理订单");
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
@@ -324,7 +325,7 @@ public class CartService {
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
if (N.gt(userCoupons.getCouponsAmount(),totalAmount)){
|
||||
if (N.gt(userCoupons.getCouponsAmount(), totalAmount)) {
|
||||
log.info("开始处理订单");
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
@@ -337,93 +338,94 @@ public class CartService {
|
||||
}
|
||||
totalAmount = totalAmount.subtract(userCoupons.getCouponsAmount());
|
||||
userCoupons.setStatus("1");
|
||||
userCoupons.setEndTime(DateUtils.getNewDate(new Date(),5,30));
|
||||
userCoupons.setEndTime(DateUtils.getNewDate(new Date(), 5, 30));
|
||||
userCouponsMapper.updateByPrimaryKeySelective(userCoupons);
|
||||
couponAmount = userCoupons.getCouponsAmount();
|
||||
}
|
||||
}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.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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
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.setUserCouponId(couponId);
|
||||
orderInfo.setUserCouponAmount(couponAmount);
|
||||
orderInfo.setAmount(totalAmount);
|
||||
orderInfo.setOriginAmount(originAmount);
|
||||
orderInfo.setOrderAmount(totalAmount.add(packAMount));
|
||||
orderInfo.setFreightAmount(BigDecimal.ZERO);
|
||||
orderInfo.setProductAmount(saleAmount);
|
||||
orderInfo.setIsBuyCoupon(isBuyYhq);
|
||||
orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
} else {
|
||||
orderInfo = getOrder(totalAmount, packAMount, shopTable, tbMerchantAccount.getId().toString(), jsonObject, originAmount);
|
||||
orderInfo.setMerchantId(String.valueOf(tbMerchantAccount.getId()));
|
||||
orderInfo.setUserCouponId(couponId);
|
||||
orderInfo.setOriginAmount(originAmount);
|
||||
orderInfo.setIsBuyCoupon(isBuyYhq);
|
||||
orderInfo.setUserCouponAmount(couponAmount);
|
||||
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);
|
||||
|
||||
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){
|
||||
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.setProductAmount(originAmount);
|
||||
orderInfo.setAmount(totalAmount);
|
||||
orderInfo.setOrderAmount(totalAmount.add(packAMount));
|
||||
orderInfo.setPayAmount(BigDecimal.ZERO);
|
||||
@@ -445,12 +447,14 @@ public class CartService {
|
||||
orderInfo.setMerchantId(merchantId);
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
public String generateOrderNumber() {
|
||||
String date = DateUtils.getSdfTimes();
|
||||
Random random = new Random();
|
||||
int randomNum = random.nextInt(900) + 100;
|
||||
return "WX" + date + randomNum;
|
||||
}
|
||||
|
||||
public void clearCart(JSONObject jsonObject) throws IOException {
|
||||
String shopId = jsonObject.getString("shopId");
|
||||
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
|
||||
|
||||
@@ -156,6 +156,11 @@ public class LoginService {
|
||||
}
|
||||
return Result.fail("登录失败");
|
||||
}
|
||||
public static void main(String[] args) throws Exception {
|
||||
String token = TokenUtil.generateToken(19, "or1l8654IFK6GIBQjK1ZKaPH3x0M",
|
||||
"19191703856", "微信用户");
|
||||
System.out.println(token);
|
||||
}
|
||||
|
||||
public TbUserInfo register(String phone, String password, String nickName) {
|
||||
|
||||
@@ -304,9 +309,5 @@ public class LoginService {
|
||||
return Result.success(CodeEnum.ENCRYPT, map);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
System.out.println(RandomUtil.randomNumbers(10));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,17 +3,20 @@ package com.chaozhanggui.system.cashierservice.service;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.CashierCarVo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.OrderVo;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
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.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.socket.AppWebSocketServer;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.N;
|
||||
import com.chaozhanggui.system.cashierservice.util.RedisUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.SnowFlakeUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -27,6 +30,7 @@ import javax.annotation.Resource;
|
||||
import java.awt.print.Pageable;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -41,7 +45,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class OrderService {
|
||||
|
||||
@Resource
|
||||
private TbShopUserMapper shopUserMapper;
|
||||
private RabbitProducer producer;
|
||||
|
||||
@Resource
|
||||
private TbOrderInfoMapper orderInfoMapper;
|
||||
@@ -62,7 +66,7 @@ public class OrderService {
|
||||
@Resource
|
||||
private TbOrderDetailMapper tbOrderDetailMapper;
|
||||
@Autowired
|
||||
private TbIntegralMapper tbIntegralMapper;
|
||||
private TbReleaseFlowMapper releaseFlowMapper;
|
||||
@Resource
|
||||
private TbParamsMapper paramsMapper;
|
||||
@Resource
|
||||
@@ -73,6 +77,8 @@ public class OrderService {
|
||||
private TbUserCouponsMapper userCouponsMapper;
|
||||
@Resource
|
||||
private TbSystemCouponsMapper systemCouponsMapper;
|
||||
@Autowired
|
||||
private TbYhqParamsMapper yhqParamsMapper;
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
@@ -253,37 +259,62 @@ public class OrderService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result tradeIntegral(String userId, String id) {
|
||||
public Result tradeIntegral(String userId, String id) throws ParseException {
|
||||
updateIntegral(userId, id);
|
||||
return Result.success(CodeEnum.ENCRYPT);
|
||||
}
|
||||
|
||||
private void updateIntegral(String userId, String id) {
|
||||
private void updateIntegral(String userId, String id) throws ParseException {
|
||||
|
||||
boolean lock_coin = redisUtils.lock(RedisCst.INTEGRAL_COIN_KEY + userId, 5000, TimeUnit.MILLISECONDS);
|
||||
if (lock_coin) {
|
||||
TbIntegral integral = tbIntegralMapper.selectByPrimaryKey(Integer.valueOf(id));
|
||||
if (Objects.isNull(integral) || !integral.getStatus().equals("1")) {
|
||||
TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(Integer.valueOf(id));
|
||||
if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0")) {
|
||||
throw new MsgException("该优惠券已被使用");
|
||||
}
|
||||
TbParams params = paramsMapper.selectByPrimaryKey(1);
|
||||
BigDecimal jfAmount = params.getTradeRatio().multiply(integral.getNum());
|
||||
TbShopUser tbShopUser = shopUserMapper.selectByUserId(userId);
|
||||
tbShopUser.setLevelConsume(tbShopUser.getLevelConsume().add(jfAmount));
|
||||
shopUserMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
integral.setStatus("TRADE");
|
||||
integral.setUpdateTime(new Date());
|
||||
tbIntegralMapper.updateByPrimaryKeySelective(integral);
|
||||
BigDecimal jfAmount = params.getTradeRatio().multiply(userCoupons.getCouponsAmount());
|
||||
TbUserInfo tbShopUser = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
tbShopUser.setTotalScore(tbShopUser.getTotalScore()+jfAmount.intValue());
|
||||
userInfoMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
userCoupons.setStatus("2");
|
||||
userCoupons.setUpdateTime(new Date());
|
||||
userCouponsMapper.updateByPrimaryKeySelective(userCoupons);
|
||||
TbSystemCoupons systemCoupons = new TbSystemCoupons();
|
||||
systemCoupons.setEndTime(DateUtils.getNewDate(new Date(),3,30));
|
||||
systemCoupons.setCouponsAmount(userCoupons.getCouponsAmount());
|
||||
systemCoupons.setCouponsPrice(userCoupons.getCouponsPrice());
|
||||
systemCoupons.setStatus("0");
|
||||
systemCoupons.setName(userCoupons.getCouponsAmount()+"无门槛优惠券");
|
||||
systemCoupons.setCreateTime(new Date());
|
||||
String typeName = findName(userCoupons.getCouponsAmount());
|
||||
systemCoupons.setTypeName(typeName);
|
||||
systemCouponsMapper.insert(systemCoupons);
|
||||
TbReleaseFlow releaseFlow = new TbReleaseFlow();
|
||||
releaseFlow.setNum(jfAmount);
|
||||
releaseFlow.setCreateTime(new Date());
|
||||
releaseFlow.setFromSource("OWER");
|
||||
releaseFlow.setUserId(userId);
|
||||
releaseFlow.setType("EXCHANGEADD");
|
||||
releaseFlowMapper.insert(releaseFlow);
|
||||
redisUtils.releaseLock(RedisCst.INTEGRAL_COIN_KEY + userId);
|
||||
} else {
|
||||
updateIntegral(userId, id);
|
||||
}
|
||||
}
|
||||
|
||||
// public Result mineYhq(String userId) {
|
||||
// List<TbIntegral> list = tbIntegralMapper.selectAllByUserId(userId);
|
||||
// return Result.success(CodeEnum.ENCRYPT, list);
|
||||
// }
|
||||
private String findName(BigDecimal amount) {
|
||||
List<TbYhqParams> list = yhqParamsMapper.selectAll();
|
||||
String typeName = "";
|
||||
for (TbYhqParams yhqParams:list){
|
||||
if (N.egt(amount,yhqParams.getMinPrice()) && N.gt(yhqParams.getMaxPrice(),amount)){
|
||||
typeName = yhqParams.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return typeName;
|
||||
}
|
||||
|
||||
|
||||
public Result mineCoupons(String userId, String status, Integer page, Integer size) {
|
||||
PageHelper.startPage(page, size);
|
||||
@@ -292,9 +323,9 @@ public class OrderService {
|
||||
return Result.success(CodeEnum.SUCCESS, pageInfo);
|
||||
}
|
||||
|
||||
public Result findCoupons(Integer page, Integer size) {
|
||||
public Result findCoupons(String type, Integer page, Integer size) {
|
||||
PageHelper.startPage(page, size);
|
||||
List<TbSystemCoupons> list = systemCouponsMapper.selectAll();
|
||||
List<TbSystemCoupons> list = systemCouponsMapper.selectAll(type);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return Result.success(CodeEnum.SUCCESS, pageInfo);
|
||||
}
|
||||
@@ -304,4 +335,28 @@ public class OrderService {
|
||||
List<TbWiningUser> list = tbWiningUserMapper.selectAllByTrade(day);
|
||||
return Result.success(CodeEnum.SUCCESS, list);
|
||||
}
|
||||
|
||||
public Result getYhqPara() {
|
||||
List<TbYhqParams> list = yhqParamsMapper.selectAll();
|
||||
return Result.success(CodeEnum.SUCCESS, list);
|
||||
}
|
||||
|
||||
public Result testPay(Integer orderId) {
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId);
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayType("wx_lite");
|
||||
orderInfo.setPayOrderNo("test");
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("token",0);
|
||||
jsonObject.put("type","wxcreate");
|
||||
jsonObject.put("orderId",orderId.toString());
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
JSONObject coupons = new JSONObject();
|
||||
coupons.put("type","buy");
|
||||
coupons.put("orderId",orderId);
|
||||
producer.printCoupons(coupons.toJSONString());
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +246,11 @@ public class PayService {
|
||||
|
||||
log.info("发送打印数据");
|
||||
producer.printMechine(orderInfo.getId() + "");
|
||||
|
||||
log.info("发送赠送购物券");
|
||||
JSONObject coupons = new JSONObject();
|
||||
coupons.put("type","buy");
|
||||
coupons.put("orderId",orderId);
|
||||
producer.printCoupons(coupons.toJSONString());
|
||||
return Result.success(CodeEnum.SUCCESS,orderId);
|
||||
case "2": //退款成功
|
||||
cartStatus="refund";
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.IntegralFlowVo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.IntegralVo;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
@@ -13,6 +14,7 @@ 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 com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -106,23 +108,17 @@ public class UserService {
|
||||
tbShopUser.setLevelConsume(tbShopUser.getLevelConsume().add(num));
|
||||
}
|
||||
if (flag) {
|
||||
TbReleaseFlow releaseFlow = new TbReleaseFlow();
|
||||
releaseFlow.setNum(num);
|
||||
releaseFlow.setCreateTime(new Date());
|
||||
releaseFlow.setFromSource("OWER");
|
||||
releaseFlow.setUserId(userId);
|
||||
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);
|
||||
}
|
||||
releaseFlowMapper.insert(releaseFlow);
|
||||
shopUserMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
}
|
||||
redisUtils.releaseLock(RedisCst.INTEGRAL_COIN_KEY + userId);
|
||||
@@ -131,4 +127,35 @@ public class UserService {
|
||||
return updateIntegral(userId, num, type);
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject userIntegral(IntegralFlowVo integralFlowVo, String userSign) {
|
||||
JSONObject object = (JSONObject) JSONObject.toJSON(integralFlowVo);
|
||||
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(integralFlowVo.getSign())) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", "fail");
|
||||
result.put("msg", "签名验证失败");
|
||||
result.put("data", "");
|
||||
return result;
|
||||
}
|
||||
TbShopUser shopUser = shopUserMapper.selectByOpenId(integralFlowVo.getOpenId());
|
||||
if (Objects.isNull(shopUser)) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", "fail");
|
||||
result.put("msg", "用户不存在");
|
||||
result.put("data", "");
|
||||
return result;
|
||||
}
|
||||
PageHelper.startPage(integralFlowVo.getPage(), integralFlowVo.getPageSize());
|
||||
PageHelper.orderBy("id DESC");
|
||||
List<TbReleaseFlow> list = releaseFlowMapper.selectByUserId(shopUser.getId());
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", "success");
|
||||
result.put("msg", "成功");
|
||||
result.put("data",list);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.chaozhanggui.system.cashierservice.sign;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.chaozhanggui.system.cashierservice.exception.IError;
|
||||
import com.chaozhanggui.system.cashierservice.util.DESUtil;
|
||||
|
||||
import java.util.List;
|
||||
@@ -143,4 +144,12 @@ public class Result {
|
||||
dto.setIcon(CodeEnum.FAIL.getIcon());
|
||||
return dto;
|
||||
}
|
||||
public static Result failure(IError error) {
|
||||
Result dto = new Result();
|
||||
dto.setMsg(error.getErrorMessage());
|
||||
dto.setEncrypt(false);
|
||||
dto.setCode(error.getErrorCode());
|
||||
dto.setIcon(CodeEnum.FAIL.getIcon());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,18 +111,6 @@ public class AppWebSocketServer {
|
||||
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);
|
||||
|
||||
@@ -1,17 +1,38 @@
|
||||
package com.chaozhanggui.system.cashierservice.task;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbUserInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbWiningParamsMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbWiningUserMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbWiningParams;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbWiningUser;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.NicknameGenerator;
|
||||
import com.chaozhanggui.system.cashierservice.util.RandomUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@Component
|
||||
public class TaskScheduler {
|
||||
|
||||
@Autowired
|
||||
private TbWiningUserMapper tbWiningUserMapper;
|
||||
|
||||
@Autowired
|
||||
private TbOrderInfoMapper orderInfoMapper;
|
||||
@Autowired
|
||||
private TbWiningParamsMapper winingParamsMapper;
|
||||
@Autowired
|
||||
private TbUserInfoMapper userInfoMapper;
|
||||
//更新订单状态
|
||||
// @Scheduled(fixedRate = 1000, initialDelay = 5000)
|
||||
public void orderStatus() throws InterruptedException {
|
||||
@@ -20,9 +41,81 @@ public class TaskScheduler {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @Scheduled(fixedRate = 1000)
|
||||
public void winningUser(){
|
||||
System.out.println("恭喜您中奖了"+DateUtils.getTime());
|
||||
public void winningUser() {
|
||||
String day = DateUtils.getDay();
|
||||
List<TbWiningParams> list = winingParamsMapper.selectAll();
|
||||
ThreadPoolExecutor es = new ThreadPoolExecutor(5, 10, 60L, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(r);
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
}
|
||||
});
|
||||
for (TbWiningParams winingParams : list) {
|
||||
es.submit(new winingUser(winingParams, day));
|
||||
}
|
||||
es.shutdown();
|
||||
|
||||
}
|
||||
|
||||
class winingUser implements Runnable {
|
||||
private TbWiningParams winingParams;
|
||||
private String day;
|
||||
|
||||
public winingUser(TbWiningParams winingParams, String day) {
|
||||
this.winingParams = winingParams;
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
List<TbOrderInfo> list = orderInfoMapper.selectByTradeDay(day, winingParams.getMinPrice(), winingParams.getMaxPrice());
|
||||
int num = winingParams.getWiningUserNum();
|
||||
List<TbOrderInfo> newList = new ArrayList<>();
|
||||
Map<Integer, Integer> map = new HashMap<>();
|
||||
int noUserNum = winingParams.getWiningNum() - num;
|
||||
if (list.size() < num) {
|
||||
noUserNum = winingParams.getWiningNum();
|
||||
} else {
|
||||
for (int i = 0; i < num; i++) {
|
||||
TbOrderInfo orderInfo = RandomUtil.selectWinner(list, map);
|
||||
newList.add(orderInfo);
|
||||
map.put(orderInfo.getId(), 1);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < noUserNum; i++) {
|
||||
long endDate = DateUtils.convertDate1(day + " 00:00:00").getTime();
|
||||
long startDate = DateUtils.convertDate1(DateUtils.getTimes(DateUtils.getNewDate(new Date(), 3, -1)) + " 00:00:00").getTime();
|
||||
String orderNo = generateOrderNumber(startDate, endDate);
|
||||
String userName = NicknameGenerator.generateRandomWeChatNickname();
|
||||
BigDecimal orderAmount = RandomUtil.getRandomBigDecimal(winingParams.getMinPrice(), winingParams.getMaxPrice());
|
||||
TbWiningUser winingUser = new TbWiningUser(userName, orderNo, orderAmount, "false", day);
|
||||
tbWiningUserMapper.insert(winingUser);
|
||||
}
|
||||
for (TbOrderInfo orderInfo:newList){
|
||||
TbUserInfo userInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId()));
|
||||
TbWiningUser winingUser = new TbWiningUser(userInfo.getNickName(), orderInfo.getOrderNo(), orderInfo.getPayAmount(), "true", day);
|
||||
tbWiningUserMapper.insert(winingUser);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String generateOrderNumber(long startTimestamp, long endTimestamp) {
|
||||
long date = getRandomTimestamp(startTimestamp, endTimestamp);
|
||||
Random random = new Random();
|
||||
int randomNum = random.nextInt(900) + 100;
|
||||
return "WX" + date + randomNum;
|
||||
}
|
||||
|
||||
public static long getRandomTimestamp(long startTimestamp, long endTimestamp) {
|
||||
long randomMilliseconds = ThreadLocalRandom.current().nextLong(startTimestamp, endTimestamp);
|
||||
return randomMilliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class NicknameGenerator {
|
||||
private static final String[] FIRST_NAMES = {
|
||||
"晓", "小", "云", "飞", "宝", "琳", "静", "翔", "晨", "昊", "若", "萌", "悦", "舒", "婷", "紫", "凡", "佳", "雨", "阳"
|
||||
};
|
||||
|
||||
private static final String[] LAST_NAMES = {
|
||||
"天", "星", "月", "琪", "雪", "梦", "婷", "晨", "宇", "瑞", "颖", "欣", "莹", "妍", "娜", "辰", "楠", "妮", "欢", "瑶"
|
||||
};
|
||||
|
||||
private static final String[] WORDS = {
|
||||
"烟火", "夜景", "小巷", "阳光", "雨滴", "星空", "花海", "梦境", "魔法", "飞翔", "童话", "温柔", "快乐", "微笑", "甜蜜", "浪漫", "幸福"
|
||||
};
|
||||
|
||||
private static final String[] EMOJIS = {
|
||||
"(^-^)", "( ̄▽ ̄)~■干杯□~( ̄▽ ̄)", "(*^▽^*)", "≧◡≦", "ヾ(≧▽≦*)o",
|
||||
"(*^3^)/~☆", "(*^▽^*)", "╰( ̄▽ ̄)╮", "(o^^)o", "(づ ̄ 3 ̄)づ"
|
||||
};
|
||||
|
||||
public static String generateRandomWeChatNickname() {
|
||||
Random random = new Random();
|
||||
String firstName = FIRST_NAMES[random.nextInt(FIRST_NAMES.length)];
|
||||
String lastName = LAST_NAMES[random.nextInt(LAST_NAMES.length)];
|
||||
String word = WORDS[random.nextInt(WORDS.length)];
|
||||
String emoji = EMOJIS[random.nextInt(EMOJIS.length)];
|
||||
return firstName + lastName + word + emoji;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomUtil {
|
||||
//获取BigDeciaml随机数
|
||||
public static BigDecimal getRandomBigDecimal(BigDecimal minAmount, BigDecimal maxAmount) {
|
||||
BigDecimal randomBigDecimal = maxAmount.subtract(minAmount).multiply(new BigDecimal(Math.random())).add(minAmount);
|
||||
return randomBigDecimal.setScale(2, RoundingMode.HALF_UP); // 设置保留两位小数并四舍五入
|
||||
}
|
||||
//获取中奖随机数
|
||||
public static TbOrderInfo selectWinner(List<TbOrderInfo> list, Map<Integer,Integer> map) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return null; // 如果用户列表为空,则返回null
|
||||
}
|
||||
|
||||
Random random = new Random();
|
||||
int randomIndex = random.nextInt(list.size()); // 生成一个随机的索引值
|
||||
TbOrderInfo orderInfo = list.get(randomIndex);
|
||||
if (map.containsKey(orderInfo.getId())){
|
||||
return selectWinner(list,map);
|
||||
}
|
||||
return list.get(randomIndex); // 返回对应索引的用户
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,9 @@ ysk:
|
||||
callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack
|
||||
default: 18710449883
|
||||
server:
|
||||
port: 9889
|
||||
port: 9888
|
||||
prod: dev1
|
||||
queue: cart_queue_putdev1
|
||||
|
||||
|
||||
|
||||
|
||||
63
src/main/resources/application-dev2.yml
Normal file
63
src/main/resources/application-dev2.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://121.40.128.145:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false
|
||||
username: root
|
||||
password: mysqlroot@123
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
maxActive: 20
|
||||
maxWait: 60000
|
||||
logging:
|
||||
level:
|
||||
com.chaozhanggui.system.openness: info
|
||||
redis:
|
||||
# redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突
|
||||
database: 5
|
||||
# redis服务器地址(默认为localhost)
|
||||
host: 101.37.12.135
|
||||
# redis端口(默认为6379)
|
||||
port: 6379
|
||||
# redis访问密码(默认为空)
|
||||
password: 111111
|
||||
# redis连接超时时间(单位为毫秒)
|
||||
timeout: 1000
|
||||
block-when-exhausted: true
|
||||
# redis连接池配置
|
||||
jedis:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-idle: 1024
|
||||
min-idle: 0
|
||||
max-wait: -1
|
||||
main:
|
||||
allow-circular-references: true
|
||||
rabbitmq:
|
||||
host: 101.37.12.135
|
||||
port: 5672
|
||||
username: admin
|
||||
password: Czg666888
|
||||
#分页配置
|
||||
pagehelper:
|
||||
supportMethodsArguments: true
|
||||
reasonable: true
|
||||
helperDialect: mysql
|
||||
params: count=countSql
|
||||
|
||||
mybatis:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
ysk:
|
||||
url: https://gatewaytestapi.sxczgkj.cn/gate-service/
|
||||
callBackurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBack
|
||||
callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack
|
||||
default: 18710449883
|
||||
server:
|
||||
port: 9889
|
||||
prod: devyhq
|
||||
queue: cart_queue_putdevyhq
|
||||
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ ysk:
|
||||
callBackurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBack
|
||||
callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack
|
||||
default: 19191703856
|
||||
prod: prod1
|
||||
queue: cart_queue_putprod1
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ ysk:
|
||||
callBackurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBack
|
||||
callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack
|
||||
default: 19191703856
|
||||
prod: prod2
|
||||
queue: cart_queue_putprod2
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
|
||||
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
|
||||
<table tableName="tb_wining_user" domainObjectName="TbWiningUser"
|
||||
<table tableName="tb_yhq_params" domainObjectName="TbYhqParams"
|
||||
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
||||
enableSelectByExample="false" selectByExampleQueryId="false" >
|
||||
</table>
|
||||
|
||||
@@ -552,4 +552,8 @@
|
||||
<select id="selectByPayOrderNo" resultMap="BaseResultMap">
|
||||
select * from tb_order_info where pay_order_no=#{payOrderNo}
|
||||
</select>
|
||||
<select id="selectByTradeDay" resultType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
|
||||
select tio1.* from tb_order_info tio1 where not EXISTS (SELECT 1 FROM `tb_order_info` toi2 where toi2.order_type = 'return' and toi2.source = tio1.id)
|
||||
and tio1.trade_day = #{day} and status = 'closed' and tio1.pay_amount >= #{minPrice} and tio1.pay_amount < #{maxPrice} and tio1.order_type = 'miniapp'
|
||||
</select>
|
||||
</mapper>
|
||||
121
src/main/resources/mapper/TbReleaseFlowMapper.xml
Normal file
121
src/main/resources/mapper/TbReleaseFlowMapper.xml
Normal file
@@ -0,0 +1,121 @@
|
||||
<?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.TbReleaseFlowMapper">
|
||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
||||
<result column="num" jdbcType="DECIMAL" property="num" />
|
||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||
<result column="from_source" jdbcType="VARCHAR" property="fromSource" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, num, type, remark, from_source, create_time
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_release_flow
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<select id="selectByUserId" resultType="com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow"
|
||||
parameterType="java.lang.String">
|
||||
select * from tb_release_flow where user_id = #{userId}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_release_flow
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow">
|
||||
insert into tb_release_flow (id, user_id, num,
|
||||
type, remark, from_source,
|
||||
create_time)
|
||||
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{num,jdbcType=DECIMAL},
|
||||
#{type,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{fromSource,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=TIMESTAMP})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow">
|
||||
insert into tb_release_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="type != null">
|
||||
type,
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="fromSource != null">
|
||||
from_source,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_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="type != null">
|
||||
#{type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
#{remark,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="fromSource != null">
|
||||
#{fromSource,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbReleaseFlow">
|
||||
update tb_release_flow
|
||||
<set>
|
||||
<if test="userId != null">
|
||||
user_id = #{userId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num = #{num,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type = #{type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
remark = #{remark,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="fromSource != null">
|
||||
from_source = #{fromSource,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.TbReleaseFlow">
|
||||
update tb_release_flow
|
||||
set user_id = #{userId,jdbcType=VARCHAR},
|
||||
num = #{num,jdbcType=DECIMAL},
|
||||
type = #{type,jdbcType=VARCHAR},
|
||||
remark = #{remark,jdbcType=VARCHAR},
|
||||
from_source = #{fromSource,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -45,6 +45,7 @@
|
||||
<result column="created_at" jdbcType="BIGINT" property="createdAt" />
|
||||
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
|
||||
<result column="proxy_id" jdbcType="VARCHAR" property="proxyId" />
|
||||
<result column="is_open_yhq" jdbcType="VARCHAR" property="isOpenYhq" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbShopInfo">
|
||||
<result column="view" jdbcType="LONGVARCHAR" property="view" />
|
||||
@@ -55,7 +56,7 @@
|
||||
detail, lat, lng, mch_id, register_type, is_wx_ma_independent, address, city, type,
|
||||
industry, industry_name, business_time, post_time, post_amount_line, on_sale, settle_type,
|
||||
settle_time, enter_at, expire_at, status, average, order_wait_pay_minute, support_device_number,
|
||||
distribute_level, created_at, updated_at, proxy_id
|
||||
distribute_level, created_at, updated_at, proxy_id,is_open_yhq
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
view
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
<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="type_name" jdbcType="VARCHAR" property="typeName" />
|
||||
<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
|
||||
id, name, coupons_price, coupons_amount, status, create_time, update_time, end_time,type_name
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
@@ -21,7 +22,7 @@
|
||||
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 * from tb_system_coupons where status = '0' and name = #{type}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_system_coupons
|
||||
@@ -30,10 +31,10 @@
|
||||
<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)
|
||||
update_time, end_time,type_name)
|
||||
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})
|
||||
#{updateTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{typeName,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons">
|
||||
insert into tb_system_coupons
|
||||
|
||||
97
src/main/resources/mapper/TbWiningParamsMapper.xml
Normal file
97
src/main/resources/mapper/TbWiningParamsMapper.xml
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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.TbWiningParamsMapper">
|
||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbWiningParams">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="min_price" jdbcType="DECIMAL" property="minPrice" />
|
||||
<result column="max_price" jdbcType="DECIMAL" property="maxPrice" />
|
||||
<result column="wining_num" jdbcType="INTEGER" property="winingNum" />
|
||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||
<result column="wining_user_num" jdbcType="INTEGER" property="winingUserNum" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, min_price, max_price, wining_num, wining_user_num,status
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_wining_params
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<select id="selectAll" resultType="com.chaozhanggui.system.cashierservice.entity.TbWiningParams">
|
||||
select * from tb_wining_params where status = 'true'
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_wining_params
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningParams">
|
||||
insert into tb_wining_params (id, min_price, max_price,
|
||||
wining_num, wining_user_num)
|
||||
values (#{id,jdbcType=INTEGER}, #{minPrice,jdbcType=DECIMAL}, #{maxPrice,jdbcType=DECIMAL},
|
||||
#{winingNum,jdbcType=INTEGER}, #{winingUserNum,jdbcType=INTEGER})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningParams">
|
||||
insert into tb_wining_params
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="minPrice != null">
|
||||
min_price,
|
||||
</if>
|
||||
<if test="maxPrice != null">
|
||||
max_price,
|
||||
</if>
|
||||
<if test="winingNum != null">
|
||||
wining_num,
|
||||
</if>
|
||||
<if test="winingUserNum != null">
|
||||
wining_user_num,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="minPrice != null">
|
||||
#{minPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="maxPrice != null">
|
||||
#{maxPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="winingNum != null">
|
||||
#{winingNum,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="winingUserNum != null">
|
||||
#{winingUserNum,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningParams">
|
||||
update tb_wining_params
|
||||
<set>
|
||||
<if test="minPrice != null">
|
||||
min_price = #{minPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="maxPrice != null">
|
||||
max_price = #{maxPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="winingNum != null">
|
||||
wining_num = #{winingNum,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="winingUserNum != null">
|
||||
wining_user_num = #{winingUserNum,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningParams">
|
||||
update tb_wining_params
|
||||
set min_price = #{minPrice,jdbcType=DECIMAL},
|
||||
max_price = #{maxPrice,jdbcType=DECIMAL},
|
||||
wining_num = #{winingNum,jdbcType=INTEGER},
|
||||
wining_user_num = #{winingUserNum,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -7,11 +7,17 @@
|
||||
<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" />
|
||||
<result column="is_refund" jdbcType="VARCHAR" property="isRefund" />
|
||||
<result column="refund_amount" jdbcType="DECIMAL" property="refundAmount" />
|
||||
<result column="refund_no" jdbcType="VARCHAR" property="refundNo" />
|
||||
<result column="refund_pay_type" jdbcType="VARCHAR" property="refundPayType" />
|
||||
<result column="trade_day" jdbcType="VARCHAR" property="tradeDay" />
|
||||
<result column="refund_time" jdbcType="TIMESTAMP" property="refundTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, user_name, order_no, order_amount, is_user, create_time,trade_day
|
||||
id, user_name, order_no, order_amount, is_user, create_time, is_refund, refund_amount,
|
||||
refund_no, refund_pay_type, trade_day, refund_time
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
@@ -19,19 +25,20 @@
|
||||
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 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
|
||||
order_amount, is_user, create_time,
|
||||
is_refund, refund_amount, refund_no,
|
||||
refund_pay_type, trade_day, refund_time
|
||||
)
|
||||
values (#{id,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR},
|
||||
#{orderAmount,jdbcType=DECIMAL}, #{isUser,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
|
||||
#{orderAmount,jdbcType=DECIMAL}, #{isUser,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
|
||||
#{isRefund,jdbcType=VARCHAR}, #{refundAmount,jdbcType=DECIMAL}, #{refundNo,jdbcType=VARCHAR},
|
||||
#{refundPayType,jdbcType=VARCHAR}, #{tradeDay,jdbcType=VARCHAR}, #{refundTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningUser">
|
||||
@@ -55,6 +62,24 @@
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="isRefund != null">
|
||||
is_refund,
|
||||
</if>
|
||||
<if test="refundAmount != null">
|
||||
refund_amount,
|
||||
</if>
|
||||
<if test="refundNo != null">
|
||||
refund_no,
|
||||
</if>
|
||||
<if test="refundPayType != null">
|
||||
refund_pay_type,
|
||||
</if>
|
||||
<if test="tradeDay != null">
|
||||
trade_day,
|
||||
</if>
|
||||
<if test="refundTime != null">
|
||||
refund_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
@@ -75,6 +100,24 @@
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="isRefund != null">
|
||||
#{isRefund,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="refundAmount != null">
|
||||
#{refundAmount,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="refundNo != null">
|
||||
#{refundNo,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="refundPayType != null">
|
||||
#{refundPayType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="tradeDay != null">
|
||||
#{tradeDay,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="refundTime != null">
|
||||
#{refundTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbWiningUser">
|
||||
@@ -95,6 +138,24 @@
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="isRefund != null">
|
||||
is_refund = #{isRefund,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="refundAmount != null">
|
||||
refund_amount = #{refundAmount,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="refundNo != null">
|
||||
refund_no = #{refundNo,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="refundPayType != null">
|
||||
refund_pay_type = #{refundPayType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="tradeDay != null">
|
||||
trade_day = #{tradeDay,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="refundTime != null">
|
||||
refund_time = #{refundTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
@@ -104,7 +165,16 @@
|
||||
order_no = #{orderNo,jdbcType=VARCHAR},
|
||||
order_amount = #{orderAmount,jdbcType=DECIMAL},
|
||||
is_user = #{isUser,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP}
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
is_refund = #{isRefund,jdbcType=VARCHAR},
|
||||
refund_amount = #{refundAmount,jdbcType=DECIMAL},
|
||||
refund_no = #{refundNo,jdbcType=VARCHAR},
|
||||
refund_pay_type = #{refundPayType,jdbcType=VARCHAR},
|
||||
trade_day = #{tradeDay,jdbcType=VARCHAR},
|
||||
refund_time = #{refundTime,jdbcType=TIMESTAMP}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<select id="selectAllByTrade" resultType="com.chaozhanggui.system.cashierservice.entity.TbWiningUser">
|
||||
select * from tb_wining_user where trade_day = #{day}
|
||||
</select>
|
||||
</mapper>
|
||||
96
src/main/resources/mapper/TbYhqParamsMapper.xml
Normal file
96
src/main/resources/mapper/TbYhqParamsMapper.xml
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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.TbYhqParamsMapper">
|
||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbYhqParams">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="min_price" jdbcType="DECIMAL" property="minPrice" />
|
||||
<result column="max_price" jdbcType="DECIMAL" property="maxPrice" />
|
||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, name, min_price, max_price, status
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_yhq_params
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<select id="selectAll" resultType="com.chaozhanggui.system.cashierservice.entity.TbYhqParams">
|
||||
select * from tb_yhq_params where status = '1' order by id asc
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_yhq_params
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbYhqParams">
|
||||
insert into tb_yhq_params (id, name, min_price,
|
||||
max_price, status)
|
||||
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{minPrice,jdbcType=DECIMAL},
|
||||
#{maxPrice,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbYhqParams">
|
||||
insert into tb_yhq_params
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="minPrice != null">
|
||||
min_price,
|
||||
</if>
|
||||
<if test="maxPrice != null">
|
||||
max_price,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status,
|
||||
</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="minPrice != null">
|
||||
#{minPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="maxPrice != null">
|
||||
#{maxPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbYhqParams">
|
||||
update tb_yhq_params
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="minPrice != null">
|
||||
min_price = #{minPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="maxPrice != null">
|
||||
max_price = #{maxPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbYhqParams">
|
||||
update tb_yhq_params
|
||||
set name = #{name,jdbcType=VARCHAR},
|
||||
min_price = #{minPrice,jdbcType=DECIMAL},
|
||||
max_price = #{maxPrice,jdbcType=DECIMAL},
|
||||
status = #{status,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user