'完成支付'

dev-discount
199901012 4 years ago
parent 7596dd8281
commit fcfa0ab93f
  1. 9
      hai-cweb/src/main/java/com/cweb/config/SysConfig.java
  2. 43
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  3. 72
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  4. 1
      hai-cweb/src/main/resources/dev/config.properties
  5. 7
      hai-service/pom.xml
  6. 41
      hai-service/src/main/java/com/hai/common/QRCodeGenerator.java
  7. 35
      hai-service/src/main/java/com/hai/dao/HighUserCouponMapper.java
  8. 72
      hai-service/src/main/java/com/hai/dao/HighUserCouponSqlProvider.java
  9. 79
      hai-service/src/main/java/com/hai/entity/HighUserCoupon.java
  10. 297
      hai-service/src/main/java/com/hai/entity/HighUserCouponExample.java
  11. 29
      hai-service/src/main/java/com/hai/service/HighGoldRecService.java
  12. 9
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  13. 7
      hai-service/src/main/java/com/hai/service/HighUserService.java
  14. 105
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  15. 44
      hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java
  16. 38
      hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java
  17. 35
      hai-service/src/main/java/com/hai/service/pay/impl/HighGoldRecServiceImpl.java

@ -16,6 +16,7 @@ public class SysConfig {
private String wxApiKey;
private String wxMchId;
private String wxUnifiedOrderUrl;
private String couponCodePath;
private String notifyUrl;
public String getFileUrl() {
@ -73,4 +74,12 @@ public class SysConfig {
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
public String getCouponCodePath() {
return couponCodePath;
}
public void setCouponCodePath(String couponCodePath) {
this.couponCodePath = couponCodePath;
}
}

@ -10,20 +10,16 @@ import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighCouponCode;
import com.hai.entity.HighOrder;
import com.hai.entity.*;
import com.hai.model.HighCouponModel;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService;
import com.hai.service.HighOrderService;
import com.hai.service.HighUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -61,6 +57,9 @@ public class HighOrderController {
@Resource
private HighCouponCodeService highCouponCodeService;
@Resource
private HighUserService highUserService;
@RequestMapping(value="/addOrder",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加订单")
@ -85,9 +84,12 @@ public class HighOrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 商品类型 1:卡卷
// 商品类型 1:卡卷 2:金币充值
if (childOrder.getGoodsType() == 1) {
if (childOrder.getSaleCount() != 1) {
log.error("HighOrderController --> addOrder() error!", "卡卷只能购买一张");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡卷只能购买一张");
}
// 查询卡卷信息
HighCouponModel coupon = highCouponService.getCouponById(childOrder.getGoodsId());
if (coupon == null) {
@ -105,11 +107,30 @@ public class HighOrderController {
childOrder.setGoodsSpecName("默认");
childOrder.setGoodsPrice(coupon.getDiscountPrice());
childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString())));
childOrder.setGiveawayType(false); // 是否是赠品 0:否 1:是
childOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
childOrder.setPraiseStatus(0);
}
if (childOrder.getGoodsType() == 2) {
if (childOrder.getGoodsPrice() == null) {
log.error("HighOrderController --> addOrder() error!", "请设置充值金额");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值金额");
}
// 查询用户信息
HighUser user = highUserService.findByUserId(childOrder.getGoodsId());
if (user == null) {
log.error("HighOrderController --> addOrder() error!", "未找到用户");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "");
}
childOrder.setGoodsName(user.getName());
childOrder.setGoodsImg(user.getHeaderImg());
childOrder.setGoodsSpecName("默认");
childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString())));
}
childOrder.setGiveawayType(false); // 是否是赠品 0:否 1:是
childOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
childOrder.setPraiseStatus(0);
// 累计订单价格
totalPrice.add(childOrder.getTotalPrice());
}

@ -13,9 +13,13 @@ import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.MathUtils;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighOrder;
import com.hai.model.HighCouponModel;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighCouponService;
import com.hai.service.HighOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -62,6 +66,9 @@ public class OrderController {
@Resource
private HighOrderService highOrderService;
@Resource
private HighCouponService highCouponService;
/**
*
* @Title: orderToPay
@ -74,8 +81,7 @@ public class OrderController {
@RequestMapping(value="/orderToPay",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "订单支付发起支付")
public ResponseData orderToPay(@RequestBody String reqBodyStr,
HttpServletRequest request) {
public ResponseData orderToPay(@RequestBody String reqBodyStr) {
try {
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
@ -100,6 +106,18 @@ public class OrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, "");
}
// 商品类型 1:卡卷 2:金币充值
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
if (childOrder.getGoodsType() == 2) {
HighCouponModel coupon = highCouponService.getCouponById(childOrder.getGoodsId());
// 支付类型:1.微信支付 2.金币支付
if (coupon.getPayType() != 1) {
log.error("OrderController --> orderToPay() ERROR", "只支持微信支持");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持微信支付");
}
}
}
Map<String,Object> map = new HashMap<>();
map.put("orderNo", order.getOrderNo());
map.put("payPrice", order.getPayPrice());
@ -133,4 +151,54 @@ public class OrderController {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/orderToGoldPay",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "订单支付发起金币支付")
public ResponseData orderToGoldPay(@RequestBody String reqBodyStr) {
try {
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
Long orderId = jsonObject.getLong("orderId");
if (orderId == null) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
HighOrder order = highOrderService.getOrderById(orderId);
if(order == null) {
log.error("OrderController --> orderToPay() ERROR", "未找到订单信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
}
//校验订单状态 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
if(order.getOrderStatus() != 1) {
log.error("OrderController --> orderToPay() ERROR", "订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, "");
}
// 商品类型 1:卡卷 2:金币充值
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
if (childOrder.getGoodsType() == 2) {
HighCouponModel coupon = highCouponService.getCouponById(childOrder.getGoodsId());
// 支付类型:1.微信支付 2.金币支付
if (coupon.getPayType() != 2) {
log.error("OrderController --> orderToPay() ERROR", "只支持金币支持");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持金币支付");
}
}
}
highOrderService.goldPayOrder(order.getMemId(), order.getId());
return ResponseMsgUtil.success("支付成功");
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -9,3 +9,4 @@ notifyUrl=https://hsgcs.dctpay.com//crest/wechatpay/notify
fileUrl=/home/project/hsg/filesystem
cmsPath=/home/project/hsg/filesystem/cmsPath
couponCodePath=/home/project/hsg/filesystem/couponCode

@ -199,7 +199,12 @@
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.0.0</version>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>

@ -0,0 +1,41 @@
package com.hai.common;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
/**
* @Auther: 胡锐
* @Description: 生成二维码
* @Date: 2021/3/27 12:07
*/
public class QRCodeGenerator {
public static void generateQRCodeImage(String text, int width, int height, String filePath) throws WriterException, IOException {
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height);
Path path = FileSystems.getDefault().getPath(filePath);
MatrixToImageWriter.writeToPath(bitMatrix, "PNG", path);
}
public static void main(String[] args) {
try {
generateQRCodeImage("This is my first QR Code", 350, 350, "D:\\qr.png");
} catch (WriterException e) {
System.out.println("Could not generate QR Code, WriterException :: " + e.getMessage());
} catch (IOException e) {
System.out.println("Could not generate QR Code, IOException :: " + e.getMessage());
}
}
}

@ -39,10 +39,14 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt {
int deleteByPrimaryKey(Long id);
@Insert({
"insert into high_user_coupon (user_id, coupon_code_id, ",
"insert into high_user_coupon (merchant_id, coupon_id, ",
"user_id, coupon_code_id, ",
"use_end_time, `status`, ",
"ext_1, ext_2, ext_3, ",
"ext_4)",
"values (#{userId,jdbcType=VARCHAR}, #{couponCodeId,jdbcType=VARCHAR}, ",
"values (#{merchantId,jdbcType=BIGINT}, #{couponId,jdbcType=BIGINT}, ",
"#{userId,jdbcType=BIGINT}, #{couponCodeId,jdbcType=BIGINT}, ",
"#{useEndTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, ",
"#{ext4,jdbcType=VARCHAR})"
})
@ -56,8 +60,12 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt {
@SelectProvider(type=HighUserCouponSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
@Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.VARCHAR),
@Result(column="merchant_id", property="merchantId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR),
@ -67,14 +75,19 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt {
@Select({
"select",
"id, user_id, coupon_code_id, ext_1, ext_2, ext_3, ext_4",
"id, merchant_id, coupon_id, user_id, coupon_code_id, use_end_time, `status`, ",
"ext_1, ext_2, ext_3, ext_4",
"from high_user_coupon",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
@Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.VARCHAR),
@Result(column="merchant_id", property="merchantId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR),
@ -93,8 +106,12 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt {
@Update({
"update high_user_coupon",
"set user_id = #{userId,jdbcType=VARCHAR},",
"coupon_code_id = #{couponCodeId,jdbcType=VARCHAR},",
"set merchant_id = #{merchantId,jdbcType=BIGINT},",
"coupon_id = #{couponId,jdbcType=BIGINT},",
"user_id = #{userId,jdbcType=BIGINT},",
"coupon_code_id = #{couponCodeId,jdbcType=BIGINT},",
"use_end_time = #{useEndTime,jdbcType=TIMESTAMP},",
"`status` = #{status,jdbcType=INTEGER},",
"ext_1 = #{ext1,jdbcType=VARCHAR},",
"ext_2 = #{ext2,jdbcType=VARCHAR},",
"ext_3 = #{ext3,jdbcType=VARCHAR},",

@ -28,12 +28,28 @@ public class HighUserCouponSqlProvider {
SQL sql = new SQL();
sql.INSERT_INTO("high_user_coupon");
if (record.getMerchantId() != null) {
sql.VALUES("merchant_id", "#{merchantId,jdbcType=BIGINT}");
}
if (record.getCouponId() != null) {
sql.VALUES("coupon_id", "#{couponId,jdbcType=BIGINT}");
}
if (record.getUserId() != null) {
sql.VALUES("user_id", "#{userId,jdbcType=VARCHAR}");
sql.VALUES("user_id", "#{userId,jdbcType=BIGINT}");
}
if (record.getCouponCodeId() != null) {
sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=VARCHAR}");
sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}");
}
if (record.getUseEndTime() != null) {
sql.VALUES("use_end_time", "#{useEndTime,jdbcType=TIMESTAMP}");
}
if (record.getStatus() != null) {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
}
if (record.getExt1() != null) {
@ -62,8 +78,12 @@ public class HighUserCouponSqlProvider {
} else {
sql.SELECT("id");
}
sql.SELECT("merchant_id");
sql.SELECT("coupon_id");
sql.SELECT("user_id");
sql.SELECT("coupon_code_id");
sql.SELECT("use_end_time");
sql.SELECT("`status`");
sql.SELECT("ext_1");
sql.SELECT("ext_2");
sql.SELECT("ext_3");
@ -89,12 +109,28 @@ public class HighUserCouponSqlProvider {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
}
if (record.getMerchantId() != null) {
sql.SET("merchant_id = #{record.merchantId,jdbcType=BIGINT}");
}
if (record.getCouponId() != null) {
sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}");
}
if (record.getUserId() != null) {
sql.SET("user_id = #{record.userId,jdbcType=VARCHAR}");
sql.SET("user_id = #{record.userId,jdbcType=BIGINT}");
}
if (record.getCouponCodeId() != null) {
sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=VARCHAR}");
sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}");
}
if (record.getUseEndTime() != null) {
sql.SET("use_end_time = #{record.useEndTime,jdbcType=TIMESTAMP}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
}
if (record.getExt1() != null) {
@ -122,8 +158,12 @@ public class HighUserCouponSqlProvider {
sql.UPDATE("high_user_coupon");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("user_id = #{record.userId,jdbcType=VARCHAR}");
sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=VARCHAR}");
sql.SET("merchant_id = #{record.merchantId,jdbcType=BIGINT}");
sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}");
sql.SET("user_id = #{record.userId,jdbcType=BIGINT}");
sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}");
sql.SET("use_end_time = #{record.useEndTime,jdbcType=TIMESTAMP}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
@ -138,12 +178,28 @@ public class HighUserCouponSqlProvider {
SQL sql = new SQL();
sql.UPDATE("high_user_coupon");
if (record.getMerchantId() != null) {
sql.SET("merchant_id = #{merchantId,jdbcType=BIGINT}");
}
if (record.getCouponId() != null) {
sql.SET("coupon_id = #{couponId,jdbcType=BIGINT}");
}
if (record.getUserId() != null) {
sql.SET("user_id = #{userId,jdbcType=VARCHAR}");
sql.SET("user_id = #{userId,jdbcType=BIGINT}");
}
if (record.getCouponCodeId() != null) {
sql.SET("coupon_code_id = #{couponCodeId,jdbcType=VARCHAR}");
sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}");
}
if (record.getUseEndTime() != null) {
sql.SET("use_end_time = #{useEndTime,jdbcType=TIMESTAMP}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{status,jdbcType=INTEGER}");
}
if (record.getExt1() != null) {

@ -1,6 +1,7 @@
package com.hai.entity;
import java.io.Serializable;
import java.util.Date;
/**
* high_user_coupon
@ -17,15 +18,35 @@ public class HighUserCoupon implements Serializable {
*/
private Long id;
/**
* 商户
*/
private Long merchantId;
/**
* 卡卷
*/
private Long couponId;
/**
* 用户id
*/
private String userId;
private Long userId;
/**
* 卡卷销售码id
*/
private Long couponCodeId;
/**
* 昵称
* 使用截止时间
*/
private String couponCodeId;
private Date useEndTime;
/**
* 状态 0:已过期 1未使用 2已使用
*/
private Integer status;
private String ext1;
@ -45,22 +66,54 @@ public class HighUserCoupon implements Serializable {
this.id = id;
}
public String getUserId() {
public Long getMerchantId() {
return merchantId;
}
public void setMerchantId(Long merchantId) {
this.merchantId = merchantId;
}
public Long getCouponId() {
return couponId;
}
public void setCouponId(Long couponId) {
this.couponId = couponId;
}
public Long getUserId() {
return userId;
}
public void setUserId(String userId) {
public void setUserId(Long userId) {
this.userId = userId;
}
public String getCouponCodeId() {
public Long getCouponCodeId() {
return couponCodeId;
}
public void setCouponCodeId(String couponCodeId) {
public void setCouponCodeId(Long couponCodeId) {
this.couponCodeId = couponCodeId;
}
public Date getUseEndTime() {
return useEndTime;
}
public void setUseEndTime(Date useEndTime) {
this.useEndTime = useEndTime;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getExt1() {
return ext1;
}
@ -106,8 +159,12 @@ public class HighUserCoupon implements Serializable {
}
HighUserCoupon other = (HighUserCoupon) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getMerchantId() == null ? other.getMerchantId() == null : this.getMerchantId().equals(other.getMerchantId()))
&& (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId()))
&& (this.getUseEndTime() == null ? other.getUseEndTime() == null : this.getUseEndTime().equals(other.getUseEndTime()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1()))
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2()))
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3()))
@ -119,8 +176,12 @@ public class HighUserCoupon implements Serializable {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getMerchantId() == null) ? 0 : getMerchantId().hashCode());
result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode());
result = prime * result + ((getUseEndTime() == null) ? 0 : getUseEndTime().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode());
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode());
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode());
@ -135,8 +196,12 @@ public class HighUserCoupon implements Serializable {
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", merchantId=").append(merchantId);
sb.append(", couponId=").append(couponId);
sb.append(", userId=").append(userId);
sb.append(", couponCodeId=").append(couponCodeId);
sb.append(", useEndTime=").append(useEndTime);
sb.append(", status=").append(status);
sb.append(", ext1=").append(ext1);
sb.append(", ext2=").append(ext2);
sb.append(", ext3=").append(ext3);

@ -1,6 +1,7 @@
package com.hai.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class HighUserCouponExample {
@ -184,6 +185,126 @@ public class HighUserCouponExample {
return (Criteria) this;
}
public Criteria andMerchantIdIsNull() {
addCriterion("merchant_id is null");
return (Criteria) this;
}
public Criteria andMerchantIdIsNotNull() {
addCriterion("merchant_id is not null");
return (Criteria) this;
}
public Criteria andMerchantIdEqualTo(Long value) {
addCriterion("merchant_id =", value, "merchantId");
return (Criteria) this;
}
public Criteria andMerchantIdNotEqualTo(Long value) {
addCriterion("merchant_id <>", value, "merchantId");
return (Criteria) this;
}
public Criteria andMerchantIdGreaterThan(Long value) {
addCriterion("merchant_id >", value, "merchantId");
return (Criteria) this;
}
public Criteria andMerchantIdGreaterThanOrEqualTo(Long value) {
addCriterion("merchant_id >=", value, "merchantId");
return (Criteria) this;
}
public Criteria andMerchantIdLessThan(Long value) {
addCriterion("merchant_id <", value, "merchantId");
return (Criteria) this;
}
public Criteria andMerchantIdLessThanOrEqualTo(Long value) {
addCriterion("merchant_id <=", value, "merchantId");
return (Criteria) this;
}
public Criteria andMerchantIdIn(List<Long> values) {
addCriterion("merchant_id in", values, "merchantId");
return (Criteria) this;
}
public Criteria andMerchantIdNotIn(List<Long> values) {
addCriterion("merchant_id not in", values, "merchantId");
return (Criteria) this;
}
public Criteria andMerchantIdBetween(Long value1, Long value2) {
addCriterion("merchant_id between", value1, value2, "merchantId");
return (Criteria) this;
}
public Criteria andMerchantIdNotBetween(Long value1, Long value2) {
addCriterion("merchant_id not between", value1, value2, "merchantId");
return (Criteria) this;
}
public Criteria andCouponIdIsNull() {
addCriterion("coupon_id is null");
return (Criteria) this;
}
public Criteria andCouponIdIsNotNull() {
addCriterion("coupon_id is not null");
return (Criteria) this;
}
public Criteria andCouponIdEqualTo(Long value) {
addCriterion("coupon_id =", value, "couponId");
return (Criteria) this;
}
public Criteria andCouponIdNotEqualTo(Long value) {
addCriterion("coupon_id <>", value, "couponId");
return (Criteria) this;
}
public Criteria andCouponIdGreaterThan(Long value) {
addCriterion("coupon_id >", value, "couponId");
return (Criteria) this;
}
public Criteria andCouponIdGreaterThanOrEqualTo(Long value) {
addCriterion("coupon_id >=", value, "couponId");
return (Criteria) this;
}
public Criteria andCouponIdLessThan(Long value) {
addCriterion("coupon_id <", value, "couponId");
return (Criteria) this;
}
public Criteria andCouponIdLessThanOrEqualTo(Long value) {
addCriterion("coupon_id <=", value, "couponId");
return (Criteria) this;
}
public Criteria andCouponIdIn(List<Long> values) {
addCriterion("coupon_id in", values, "couponId");
return (Criteria) this;
}
public Criteria andCouponIdNotIn(List<Long> values) {
addCriterion("coupon_id not in", values, "couponId");
return (Criteria) this;
}
public Criteria andCouponIdBetween(Long value1, Long value2) {
addCriterion("coupon_id between", value1, value2, "couponId");
return (Criteria) this;
}
public Criteria andCouponIdNotBetween(Long value1, Long value2) {
addCriterion("coupon_id not between", value1, value2, "couponId");
return (Criteria) this;
}
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
@ -194,62 +315,52 @@ public class HighUserCouponExample {
return (Criteria) this;
}
public Criteria andUserIdEqualTo(String value) {
public Criteria andUserIdEqualTo(Long value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotEqualTo(String value) {
public Criteria andUserIdNotEqualTo(Long value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThan(String value) {
public Criteria andUserIdGreaterThan(Long value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThanOrEqualTo(String value) {
public Criteria andUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThan(String value) {
public Criteria andUserIdLessThan(Long value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThanOrEqualTo(String value) {
public Criteria andUserIdLessThanOrEqualTo(Long value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLike(String value) {
addCriterion("user_id like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotLike(String value) {
addCriterion("user_id not like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdIn(List<String> values) {
public Criteria andUserIdIn(List<Long> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<String> values) {
public Criteria andUserIdNotIn(List<Long> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdBetween(String value1, String value2) {
public Criteria andUserIdBetween(Long value1, Long value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotBetween(String value1, String value2) {
public Criteria andUserIdNotBetween(Long value1, Long value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}
@ -264,63 +375,173 @@ public class HighUserCouponExample {
return (Criteria) this;
}
public Criteria andCouponCodeIdEqualTo(String value) {
public Criteria andCouponCodeIdEqualTo(Long value) {
addCriterion("coupon_code_id =", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdNotEqualTo(String value) {
public Criteria andCouponCodeIdNotEqualTo(Long value) {
addCriterion("coupon_code_id <>", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdGreaterThan(String value) {
public Criteria andCouponCodeIdGreaterThan(Long value) {
addCriterion("coupon_code_id >", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdGreaterThanOrEqualTo(String value) {
public Criteria andCouponCodeIdGreaterThanOrEqualTo(Long value) {
addCriterion("coupon_code_id >=", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdLessThan(String value) {
public Criteria andCouponCodeIdLessThan(Long value) {
addCriterion("coupon_code_id <", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdLessThanOrEqualTo(String value) {
public Criteria andCouponCodeIdLessThanOrEqualTo(Long value) {
addCriterion("coupon_code_id <=", value, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdLike(String value) {
addCriterion("coupon_code_id like", value, "couponCodeId");
public Criteria andCouponCodeIdIn(List<Long> values) {
addCriterion("coupon_code_id in", values, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdNotLike(String value) {
addCriterion("coupon_code_id not like", value, "couponCodeId");
public Criteria andCouponCodeIdNotIn(List<Long> values) {
addCriterion("coupon_code_id not in", values, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdIn(List<String> values) {
addCriterion("coupon_code_id in", values, "couponCodeId");
public Criteria andCouponCodeIdBetween(Long value1, Long value2) {
addCriterion("coupon_code_id between", value1, value2, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdNotIn(List<String> values) {
addCriterion("coupon_code_id not in", values, "couponCodeId");
public Criteria andCouponCodeIdNotBetween(Long value1, Long value2) {
addCriterion("coupon_code_id not between", value1, value2, "couponCodeId");
return (Criteria) this;
}
public Criteria andCouponCodeIdBetween(String value1, String value2) {
addCriterion("coupon_code_id between", value1, value2, "couponCodeId");
public Criteria andUseEndTimeIsNull() {
addCriterion("use_end_time is null");
return (Criteria) this;
}
public Criteria andCouponCodeIdNotBetween(String value1, String value2) {
addCriterion("coupon_code_id not between", value1, value2, "couponCodeId");
public Criteria andUseEndTimeIsNotNull() {
addCriterion("use_end_time is not null");
return (Criteria) this;
}
public Criteria andUseEndTimeEqualTo(Date value) {
addCriterion("use_end_time =", value, "useEndTime");
return (Criteria) this;
}
public Criteria andUseEndTimeNotEqualTo(Date value) {
addCriterion("use_end_time <>", value, "useEndTime");
return (Criteria) this;
}
public Criteria andUseEndTimeGreaterThan(Date value) {
addCriterion("use_end_time >", value, "useEndTime");
return (Criteria) this;
}
public Criteria andUseEndTimeGreaterThanOrEqualTo(Date value) {
addCriterion("use_end_time >=", value, "useEndTime");
return (Criteria) this;
}
public Criteria andUseEndTimeLessThan(Date value) {
addCriterion("use_end_time <", value, "useEndTime");
return (Criteria) this;
}
public Criteria andUseEndTimeLessThanOrEqualTo(Date value) {
addCriterion("use_end_time <=", value, "useEndTime");
return (Criteria) this;
}
public Criteria andUseEndTimeIn(List<Date> values) {
addCriterion("use_end_time in", values, "useEndTime");
return (Criteria) this;
}
public Criteria andUseEndTimeNotIn(List<Date> values) {
addCriterion("use_end_time not in", values, "useEndTime");
return (Criteria) this;
}
public Criteria andUseEndTimeBetween(Date value1, Date value2) {
addCriterion("use_end_time between", value1, value2, "useEndTime");
return (Criteria) this;
}
public Criteria andUseEndTimeNotBetween(Date value1, Date value2) {
addCriterion("use_end_time not between", value1, value2, "useEndTime");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(Integer value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(Integer value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(Integer value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(Integer value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(Integer value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<Integer> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<Integer> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(Integer value1, Integer value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(Integer value1, Integer value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}

@ -0,0 +1,29 @@
package com.hai.service;
import com.hai.entity.HighGoldRec;
import java.util.List;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description: 金币记录
* @Date: 2021/3/27 10:01
*/
public interface HighGoldRecService {
/**
* @Author 胡锐
* @Description 增加记录
* @Date 2021/3/27 10:02
**/
void insertGoldRec(HighGoldRec highGoldRec);
/**
* @Author 胡锐
* @Description 查询记录
* @Date 2021/3/27 10:03
**/
List<HighGoldRec> getGoldRec(Map<String, Object> map);
}

@ -17,7 +17,14 @@ public interface HighOrderService {
* @Description 增加订单
* @Date 2021/3/26 23:05
**/
void insertOrder(HighOrder highOrder);
void insertOrder(HighOrder highOrder) throws Exception;
/**
* @Author 胡锐
* @Description 金币支付订单
* @Date 2021/3/27 11:20
**/
void goldPayOrder(Long userId, Long orderId);
/**
* @Author 胡锐

@ -75,4 +75,11 @@ public interface HighUserService {
*/
void insertUser(HighUser highUser);
/**
* @Author 胡锐
* @Description 用户金币充值消费
* @Date 2021/3/27 9:51
**/
void goldHandle(Long userId, Integer goldNum, Integer goldType, Integer resType, Long resId);
}

@ -1,19 +1,27 @@
package com.hai.service.impl;
import com.hai.common.QRCodeGenerator;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.dao.HighChildOrderMapper;
import com.hai.dao.HighOrderMapper;
import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.*;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighOrderService;
import com.hai.model.HighCouponHandselModel;
import com.hai.model.HighCouponModel;
import com.hai.service.*;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.File;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -35,9 +43,21 @@ public class HighOrderServiceImpl implements HighOrderService {
@Resource
private HighCouponCodeService highCouponCodeService;
@Resource
private HighCouponService highCouponService;
@Resource
private HighCouponHandselService highCouponHandselService;
@Resource
private HighUserService highUserService;
@Resource
private HighUserCouponMapper highUserCouponMapper;
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void insertOrder(HighOrder highOrder) {
public void insertOrder(HighOrder highOrder) throws Exception {
highOrderMapper.insert(highOrder);
for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
@ -54,10 +74,89 @@ public class HighOrderServiceImpl implements HighOrderService {
list.get(0).setChildOrderId(childOrder.getId());
list.get(0).setStatus(99); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
highCouponCodeService.updateCouponCode(list.get(0));
// 生成二维码
String qrCodeUrl = "/home/project/hsg/filesystem/couponCode/"+DateUtil.date2String(new Date(),"yyyyMMddHHmmss")+".png";
QRCodeGenerator.generateQRCodeImage(list.get(0).getSalesCode(), 350, 350, qrCodeUrl);
childOrder.setExt1(qrCodeUrl);
highChildOrderMapper.updateByPrimaryKey(childOrder);
if(childOrder.getGiveawayType() == false) {
// 查看是否需要赠送卡卷
List<HighCouponHandselModel> handselListByCoupon = highCouponHandselService.getHandselListByCoupon(childOrder.getGoodsId());
if (handselListByCoupon != null && handselListByCoupon.size() > 0) {
for (HighCouponHandsel highCouponHandsel : handselListByCoupon) {
// 查询卡卷信息
HighCouponModel coupon = highCouponService.getCouponById(highCouponHandsel.getId());
if (coupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
// 查询赠送卡卷 是否有库存,没有就不赠送
if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) <= 0) {
HighChildOrder highChildOrder = new HighChildOrder();
highChildOrder.setOrderId(highOrder.getId());
highChildOrder.setGoodsType(1);
highChildOrder.setGoodsId(coupon.getId());
highChildOrder.setGoodsName(coupon.getCouponName());
highChildOrder.setGoodsImg(coupon.getCouponImg());
highChildOrder.setGoodsSpecName("默认");
highChildOrder.setGoodsPrice(new BigDecimal(0));
highChildOrder.setSaleCount(1);
highChildOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString())));
highChildOrder.setGiveawayType(true); // 是否是赠品 0:否 1:是
highChildOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
highChildOrder.setPraiseStatus(0);
highOrder.getHighChildOrderList().add(highChildOrder);
}
}
}
}
}
}
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void goldPayOrder(Long userId, Long orderId) {
HighOrder highOrder = getOrderById(orderId);
if(highOrder == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
}
// 金币 1:100
Integer goldNum = new BigDecimal(highOrder.getTotalPrice().toString()).multiply(new BigDecimal("100")).intValue();
highUserService.goldHandle(userId, goldNum, 2, 2, highOrder.getId());
highOrder.setPayTime(new Date()); // 支付时间
highOrder.setPayModel(1); // 支付模式:1 金币,2 第三方平台,3 混合
highOrder.setPayType(3); // 支付方式: 1:支付宝 2:微信 3:金币
highOrder.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
for (HighChildOrder highChildOrder : highOrder.getHighChildOrderList()) {
highChildOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
// 商品类型 商品类型 1:卡卷 2:金币充值
if (highChildOrder.getGoodsType() == 1) {
HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId());
code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
highCouponCodeService.updateCouponCode(code);
// 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(code.getMerchantId());
highUserCoupon.setCouponId(code.getCouponId());
highUserCoupon.setUserId(highOrder.getMemId());
highUserCoupon.setCouponCodeId(code.getId());
highUserCoupon.setUseEndTime(code.getUseEndTime());
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon);
}
}
updateOrder(highOrder);
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void updateOrder(HighOrder highOrder) {

@ -1,14 +1,22 @@
package com.hai.service.impl;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil;
import com.hai.dao.HighUserMapper;
import com.hai.entity.HighGoldRec;
import com.hai.entity.HighUser;
import com.hai.entity.HighUserExample;
import com.hai.service.HighGoldRecService;
import com.hai.service.HighUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -21,6 +29,9 @@ public class HighUserServiceImpl implements HighUserService {
@Resource
private HighUserMapper highUserMapper;
@Resource
private HighGoldRecService highGoldRecService;
@Override
public List<HighUser> getListUser(Map<String, String> map) {
@ -82,4 +93,37 @@ public class HighUserServiceImpl implements HighUserService {
public void insertUser(HighUser highUser) {
highUserMapper.insert(highUser);
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void goldHandle(Long userId, Integer goldNum, Integer goldType, Integer resType, Long resId) {
// 查询用户信息
HighUser user = highUserMapper.selectByPrimaryKey(userId);
if (user == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "");
}
// 金币类型:1收入,2支出
if (goldType == 1) {
user.setGold(user.getGold() + goldNum);
} else if (goldType == 2) {
if (goldNum > user.getGold()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "金币数量不足");
}
user.setGold(user.getGold() - goldNum);
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户金币处理异常");
}
HighGoldRec highGoldRec = new HighGoldRec();
highGoldRec.setUserId(user.getId());
highGoldRec.setGoldType(goldType.longValue());
highGoldRec.setGold(goldNum);
highGoldRec.setCreateTime(new Date());
highGoldRec.setResType(resType);
highGoldRec.setResId(resId);
highGoldRecService.insertGoldRec(highGoldRec);
}
}

@ -4,14 +4,16 @@ import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighCouponCode;
import com.hai.entity.HighOrder;
import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.*;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighOrderService;
import com.hai.service.HighUserService;
import com.hai.service.pay.PayService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
@ -33,7 +35,14 @@ public class GoodsOrderServiceImpl implements PayService {
@Resource
private HighCouponCodeService highCouponCodeService;
@Resource
private HighUserService highUserService;
@Resource
private HighUserCouponMapper highUserCouponMapper;
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void paySuccess(Map<String, String> map, String payType) throws Exception {
if (payType.equals("Alipay")) {
// 支付宝支付 todo 暂未开发
@ -55,15 +64,32 @@ public class GoodsOrderServiceImpl implements PayService {
for (HighChildOrder highChildOrder : order.getHighChildOrderList()) {
highChildOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
// 商品类型 1:卡卷
// 商品类型 商品类型 1:卡卷 2:金币充值
if (highChildOrder.getGoodsType() == 1) {
// highCouponCodeService.getCouponCodeById(highChildOrder.get)
HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId());
code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
highCouponCodeService.updateCouponCode(code);
// 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(code.getMerchantId());
highUserCoupon.setCouponId(code.getCouponId());
highUserCoupon.setUserId(order.getMemId());
highUserCoupon.setCouponCodeId(code.getId());
highUserCoupon.setUseEndTime(code.getUseEndTime());
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon);
}
if (highChildOrder.getGoodsType() == 2) {
// 金币 1:100
Integer goldNum = new BigDecimal(highChildOrder.getTotalPrice().toString()).multiply(new BigDecimal("100")).intValue();
highUserService.goldHandle(highChildOrder.getGoodsId(), goldNum, 1, 1, highChildOrder.getId());
}
}
highOrderService.updateOrder(order);
}
}
}

@ -0,0 +1,35 @@
package com.hai.service.pay.impl;
import com.hai.dao.HighGoldRecMapper;
import com.hai.entity.HighGoldRec;
import com.hai.entity.HighGoldRecExample;
import com.hai.service.HighGoldRecService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/27 10:03
*/
@Service("highGoldRecService")
public class HighGoldRecServiceImpl implements HighGoldRecService {
@Resource
private HighGoldRecMapper highGoldRecMapper;
@Override
public void insertGoldRec(HighGoldRec highGoldRec) {
highGoldRecMapper.insert(highGoldRec);
}
@Override
public List<HighGoldRec> getGoldRec(Map<String, Object> map) {
HighGoldRecExample example = new HighGoldRecExample();
return highGoldRecMapper.selectByExample(example);
}
}
Loading…
Cancel
Save