diff --git a/README.md b/README.md index 7273a5ed..4be8b34f 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ yshop基于当前流行技术组合的前后端分离商城系统: SpringBoot2 - 1.6、修复拼团出现undefined - 1.7、会员后台新增余额调整 - 1.8、修复新增配置数据有时候不成功问题等 +- 1.4.1个人中心新增账单流水 #### 反馈交流 diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/entity/YxUserRecharge.java b/yshop-api/src/main/java/co/yixiang/modules/user/entity/YxUserRecharge.java new file mode 100644 index 00000000..c2c2a8fc --- /dev/null +++ b/yshop-api/src/main/java/co/yixiang/modules/user/entity/YxUserRecharge.java @@ -0,0 +1,57 @@ +package co.yixiang.modules.user.entity; + +import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.IdType; +import co.yixiang.common.entity.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + *

+ * 用户充值表 + *

+ * + * @author hupeng + * @since 2019-12-08 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "YxUserRecharge对象", description = "用户充值表") +public class YxUserRecharge extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "充值用户UID") + private Integer uid; + + @ApiModelProperty(value = "订单号") + private String orderId; + + @ApiModelProperty(value = "充值金额") + private BigDecimal price; + + @ApiModelProperty(value = "充值类型") + private String rechargeType; + + @ApiModelProperty(value = "是否充值") + private Integer paid; + + @ApiModelProperty(value = "充值支付时间") + private Integer payTime; + + @ApiModelProperty(value = "充值时间") + private Integer addTime; + + @ApiModelProperty(value = "退款金额") + private BigDecimal refundPrice; + +} diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/mapper/YxUserRechargeMapper.java b/yshop-api/src/main/java/co/yixiang/modules/user/mapper/YxUserRechargeMapper.java new file mode 100644 index 00000000..11768f66 --- /dev/null +++ b/yshop-api/src/main/java/co/yixiang/modules/user/mapper/YxUserRechargeMapper.java @@ -0,0 +1,40 @@ +package co.yixiang.modules.user.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import co.yixiang.modules.user.entity.YxUserRecharge; +import co.yixiang.modules.user.web.param.YxUserRechargeQueryParam; +import co.yixiang.modules.user.web.vo.YxUserRechargeQueryVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.io.Serializable; + +/** + *

+ * 用户充值表 Mapper 接口 + *

+ * + * @author hupeng + * @since 2019-12-08 + */ +@Repository +public interface YxUserRechargeMapper extends BaseMapper { + + /** + * 根据ID获取查询对象 + * @param id + * @return + */ + YxUserRechargeQueryVo getYxUserRechargeById(Serializable id); + + /** + * 获取分页对象 + * @param page + * @param yxUserRechargeQueryParam + * @return + */ + IPage getYxUserRechargePageList(@Param("page") Page page, @Param("param") YxUserRechargeQueryParam yxUserRechargeQueryParam); + +} diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/service/YxUserRechargeService.java b/yshop-api/src/main/java/co/yixiang/modules/user/service/YxUserRechargeService.java new file mode 100644 index 00000000..24d17e5b --- /dev/null +++ b/yshop-api/src/main/java/co/yixiang/modules/user/service/YxUserRechargeService.java @@ -0,0 +1,38 @@ +package co.yixiang.modules.user.service; + +import co.yixiang.modules.user.entity.YxUserRecharge; +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.user.web.param.RechargeParam; +import co.yixiang.modules.user.web.param.YxUserRechargeQueryParam; +import co.yixiang.modules.user.web.vo.YxUserRechargeQueryVo; +import co.yixiang.common.web.vo.Paging; + +import java.io.Serializable; + +/** + *

+ * 用户充值表 服务类 + *

+ * + * @author hupeng + * @since 2019-12-08 + */ +public interface YxUserRechargeService extends BaseService { + + void addRecharge(RechargeParam param,int uid); + + /** + * 根据ID获取查询对象 + * @param id + * @return + */ + YxUserRechargeQueryVo getYxUserRechargeById(Serializable id) throws Exception; + + /** + * 获取分页对象 + * @param yxUserRechargeQueryParam + * @return + */ + Paging getYxUserRechargePageList(YxUserRechargeQueryParam yxUserRechargeQueryParam) throws Exception; + +} diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/service/impl/YxUserRechargeServiceImpl.java b/yshop-api/src/main/java/co/yixiang/modules/user/service/impl/YxUserRechargeServiceImpl.java new file mode 100644 index 00000000..b64d27ff --- /dev/null +++ b/yshop-api/src/main/java/co/yixiang/modules/user/service/impl/YxUserRechargeServiceImpl.java @@ -0,0 +1,73 @@ +package co.yixiang.modules.user.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.modules.user.entity.YxUserRecharge; +import co.yixiang.modules.user.mapper.YxUserRechargeMapper; +import co.yixiang.modules.user.service.YxUserRechargeService; +import co.yixiang.modules.user.web.param.RechargeParam; +import co.yixiang.modules.user.web.param.YxUserRechargeQueryParam; +import co.yixiang.modules.user.web.vo.YxUserRechargeQueryVo; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.web.vo.Paging; +import co.yixiang.utils.OrderUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.io.Serializable; +import java.math.BigDecimal; + + +/** + *

+ * 用户充值表 服务实现类 + *

+ * + * @author hupeng + * @since 2019-12-08 + */ +@Slf4j +@Service +@Transactional(rollbackFor = Exception.class) +public class YxUserRechargeServiceImpl extends BaseServiceImpl implements YxUserRechargeService { + + @Autowired + private YxUserRechargeMapper yxUserRechargeMapper; + + + /** + * 充值(废弃掉) + * @param param + */ + @Override + public void addRecharge(RechargeParam param,int uid) { + YxUserRecharge yxUserRecharge = new YxUserRecharge(); + String orderId = "re_"+OrderUtil.orderSn(); + yxUserRecharge.setOrderId(orderId); + yxUserRecharge.setUid(uid); + yxUserRecharge.setPrice(BigDecimal.valueOf(param.getPrice())); + yxUserRecharge.setRechargeType("weixin"); + yxUserRecharge.setPaid(0); + yxUserRecharge.setAddTime(OrderUtil.getSecondTimestampTwo()); + + yxUserRechargeMapper.insert(yxUserRecharge); + + } + + @Override + public YxUserRechargeQueryVo getYxUserRechargeById(Serializable id) throws Exception{ + return yxUserRechargeMapper.getYxUserRechargeById(id); + } + + @Override + public Paging getYxUserRechargePageList(YxUserRechargeQueryParam yxUserRechargeQueryParam) throws Exception{ + Page page = setPageParam(yxUserRechargeQueryParam,OrderItem.desc("create_time")); + IPage iPage = yxUserRechargeMapper.getYxUserRechargePageList(page,yxUserRechargeQueryParam); + return new Paging(iPage); + } + +} diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/UserRechargeController.java b/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/UserRechargeController.java new file mode 100644 index 00000000..f2017d2d --- /dev/null +++ b/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/UserRechargeController.java @@ -0,0 +1,65 @@ +package co.yixiang.modules.user.web.controller; + +import cn.hutool.core.util.StrUtil; +import co.yixiang.common.api.ApiResult; +import co.yixiang.common.web.controller.BaseController; +import co.yixiang.common.web.param.IdParam; +import co.yixiang.common.web.vo.Paging; +import co.yixiang.modules.user.entity.YxUserAddress; +import co.yixiang.modules.user.entity.YxUserRecharge; +import co.yixiang.modules.user.service.YxUserRechargeService; +import co.yixiang.modules.user.web.param.AddressParam; +import co.yixiang.modules.user.web.param.RechargeParam; +import co.yixiang.modules.user.web.param.YxUserRechargeQueryParam; +import co.yixiang.modules.user.web.vo.YxUserRechargeQueryVo; +import co.yixiang.utils.OrderUtil; +import co.yixiang.utils.SecurityUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + *

+ * 用户充值 前端控制器 + *

+ * + * @author hupeng + * @since 2019-12-08 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "用户充值", tags = "用户充值", description = "用户充值") +public class UserRechargeController extends BaseController { + + + private final YxUserRechargeService userRechargeService; + + /** + * 公众号充值 + */ + @PostMapping("/recharge/wechat") + @ApiOperation(value = "公众号充值",notes = "公众号充值",response = ApiResult.class) + public ApiResult> add(@Valid @RequestBody RechargeParam param){ + int uid = SecurityUtils.getUserId().intValue(); + + Map map = new LinkedHashMap<>(); + map.put("id",null); + return ApiResult.ok(map); + } + + + + +} + diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/YxUserRechargeController.java b/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/YxUserRechargeController.java new file mode 100644 index 00000000..e58a2db0 --- /dev/null +++ b/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/YxUserRechargeController.java @@ -0,0 +1,91 @@ +package co.yixiang.modules.user.web.controller; + +import co.yixiang.modules.user.entity.YxUserRecharge; +import co.yixiang.modules.user.service.YxUserRechargeService; +import co.yixiang.modules.user.web.param.YxUserRechargeQueryParam; +import co.yixiang.modules.user.web.vo.YxUserRechargeQueryVo; +import co.yixiang.common.web.controller.BaseController; +import co.yixiang.common.api.ApiResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; + +import co.yixiang.common.web.vo.Paging; +import co.yixiang.common.web.param.IdParam; + +/** + *

+ * 用户充值表 前端控制器 + *

+ * + * @author hupeng + * @since 2019-12-08 + */ +@Slf4j +@RestController +@RequestMapping("/yxUserRecharge") +@Api("用户充值表 API") +public class YxUserRechargeController extends BaseController { + + @Autowired + private YxUserRechargeService yxUserRechargeService; + + /** + * 添加用户充值表 + */ + @PostMapping("/add") + @ApiOperation(value = "添加YxUserRecharge对象",notes = "添加用户充值表",response = ApiResult.class) + public ApiResult addYxUserRecharge(@Valid @RequestBody YxUserRecharge yxUserRecharge) throws Exception{ + boolean flag = yxUserRechargeService.save(yxUserRecharge); + return ApiResult.result(flag); + } + + /** + * 修改用户充值表 + */ + @PostMapping("/update") + @ApiOperation(value = "修改YxUserRecharge对象",notes = "修改用户充值表",response = ApiResult.class) + public ApiResult updateYxUserRecharge(@Valid @RequestBody YxUserRecharge yxUserRecharge) throws Exception{ + boolean flag = yxUserRechargeService.updateById(yxUserRecharge); + return ApiResult.result(flag); + } + + /** + * 删除用户充值表 + */ + @PostMapping("/delete") + @ApiOperation(value = "删除YxUserRecharge对象",notes = "删除用户充值表",response = ApiResult.class) + public ApiResult deleteYxUserRecharge(@Valid @RequestBody IdParam idParam) throws Exception{ + boolean flag = yxUserRechargeService.removeById(idParam.getId()); + return ApiResult.result(flag); + } + + /** + * 获取用户充值表 + */ + @PostMapping("/info") + @ApiOperation(value = "获取YxUserRecharge对象详情",notes = "查看用户充值表",response = YxUserRechargeQueryVo.class) + public ApiResult getYxUserRecharge(@Valid @RequestBody IdParam idParam) throws Exception{ + YxUserRechargeQueryVo yxUserRechargeQueryVo = yxUserRechargeService.getYxUserRechargeById(idParam.getId()); + return ApiResult.ok(yxUserRechargeQueryVo); + } + + /** + * 用户充值表分页列表 + */ + @PostMapping("/getPageList") + @ApiOperation(value = "获取YxUserRecharge分页列表",notes = "用户充值表分页列表",response = YxUserRechargeQueryVo.class) + public ApiResult> getYxUserRechargePageList(@Valid @RequestBody(required = false) YxUserRechargeQueryParam yxUserRechargeQueryParam) throws Exception{ + Paging paging = yxUserRechargeService.getYxUserRechargePageList(yxUserRechargeQueryParam); + return ApiResult.ok(paging); + } + +} + diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/web/param/RechargeParam.java b/yshop-api/src/main/java/co/yixiang/modules/user/web/param/RechargeParam.java new file mode 100644 index 00000000..2b061f84 --- /dev/null +++ b/yshop-api/src/main/java/co/yixiang/modules/user/web/param/RechargeParam.java @@ -0,0 +1,21 @@ +package co.yixiang.modules.user.web.param; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @ClassName RechargeParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/8 + **/ +@Data +public class RechargeParam implements Serializable { + private String from; + + @NotNull(message = "金额必填") + @Min(value = 1,message = "充值金额不能低于1") + private Double price; +} diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/web/param/YxUserRechargeQueryParam.java b/yshop-api/src/main/java/co/yixiang/modules/user/web/param/YxUserRechargeQueryParam.java new file mode 100644 index 00000000..f489d567 --- /dev/null +++ b/yshop-api/src/main/java/co/yixiang/modules/user/web/param/YxUserRechargeQueryParam.java @@ -0,0 +1,22 @@ +package co.yixiang.modules.user.web.param; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import co.yixiang.common.web.param.QueryParam; + +/** + *

+ * 用户充值表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-08 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxUserRechargeQueryParam对象", description="用户充值表查询参数") +public class YxUserRechargeQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/web/vo/YxUserRechargeQueryVo.java b/yshop-api/src/main/java/co/yixiang/modules/user/web/vo/YxUserRechargeQueryVo.java new file mode 100644 index 00000000..69b47aa7 --- /dev/null +++ b/yshop-api/src/main/java/co/yixiang/modules/user/web/vo/YxUserRechargeQueryVo.java @@ -0,0 +1,51 @@ +package co.yixiang.modules.user.web.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +import java.math.BigDecimal; +import java.util.Date; + +/** + *

+ * 用户充值表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-08 + */ +@Data +@ApiModel(value = "YxUserRechargeQueryVo对象", description = "用户充值表查询参数") +public class YxUserRechargeQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer id; + + @ApiModelProperty(value = "充值用户UID") + private Integer uid; + + @ApiModelProperty(value = "订单号") + private String orderId; + + @ApiModelProperty(value = "充值金额") + private BigDecimal price; + + @ApiModelProperty(value = "充值类型") + private String rechargeType; + + @ApiModelProperty(value = "是否充值") + private Integer paid; + + @ApiModelProperty(value = "充值支付时间") + private Integer payTime; + + @ApiModelProperty(value = "充值时间") + private Integer addTime; + + @ApiModelProperty(value = "退款金额") + private BigDecimal refundPrice; + +} \ No newline at end of file diff --git a/yshop-api/src/main/resources/mapper/user/YxUserRechargeMapper.xml b/yshop-api/src/main/resources/mapper/user/YxUserRechargeMapper.xml new file mode 100644 index 00000000..ee24c7be --- /dev/null +++ b/yshop-api/src/main/resources/mapper/user/YxUserRechargeMapper.xml @@ -0,0 +1,18 @@ + + + + + + + id, uid, order_id, price, recharge_type, paid, pay_time, add_time, refund_price + + + + + + + diff --git a/yshop-api/src/test/java/co/yixiang/test/CodeGenerator.java b/yshop-api/src/test/java/co/yixiang/test/CodeGenerator.java index e1ede55f..bdd0cd08 100644 --- a/yshop-api/src/test/java/co/yixiang/test/CodeGenerator.java +++ b/yshop-api/src/test/java/co/yixiang/test/CodeGenerator.java @@ -47,7 +47,7 @@ public class CodeGenerator { // 作者 private static final String AUTHOR = "hupeng"; // 生成的表名称 - private static final String TABLE_NAME = "yx_user_task_finish"; // 主键数据库列名称 + private static final String TABLE_NAME = "yx_user_recharge"; // 主键数据库列名称 private static final String PK_ID_COLUMN_NAME = "id"; // 代码生成策略 true:All/false:SIMPLE private static final boolean GENERATOR_STRATEGY = true;