chengpeng 5 gadi atpakaļ
vecāks
revīzija
cd409cf26c

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRechargeDao.java

@@ -5,5 +5,7 @@ import com.ym.mec.common.dal.BaseDAO;
 
 public interface StudentRechargeDao extends BaseDAO<String, StudentRecharge> {
 
+
+    StudentRecharge selectByTransNo(String transNo);
 	
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysUserCashAccountDetailDao.java

@@ -5,5 +5,5 @@ import com.ym.mec.common.dal.BaseDAO;
 
 public interface SysUserCashAccountDetailDao extends BaseDAO<Long, SysUserCashAccountDetail> {
 
-	
+    SysUserCashAccountDetail selectDetailByTransNo(String transNo);
 }

+ 136 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentCashDetailQueryInfo.java

@@ -0,0 +1,136 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author : chengp
+ * @version V1.0
+ * @Description: TODO
+ * @date Date : 2019年09月24日 10:07
+ */
+public class StudentCashDetailQueryInfo extends QueryInfo {
+
+    /** 用户编号 */
+    @ApiModelProperty(value = "用户编号",required = false)
+    private Integer userId;
+
+    /** 交易流水号 */
+    @ApiModelProperty(value = "交易流水号",required = false)
+    private String transNo;
+
+    /** 交易类型 (RECHARGE 充值,WITHDRAW 提现,PAY_FEE 缴费,REFUNDS 退费,FILL_ACCOUNT 人工补账) */
+    @ApiModelProperty(value = "交易类型",required = false)
+    private PlatformCashAccountDetailTypeEnum type;
+
+    /** 交易状态(1,交易中;2,成功交易;-1,交易失败;) */
+    @ApiModelProperty(value = "交易状态",required = false)
+    private DealStatusEnum status;
+
+    /** 交易金额 */
+    @ApiModelProperty(value = "交易金额",required = false)
+    private BigDecimal amount;
+
+    /** 账户可用余额 */
+    @ApiModelProperty(value = "账户可用余额",required = false)
+    private BigDecimal balance;
+
+    /** 描述 */
+    @ApiModelProperty(value = "描述",required = false)
+    private String description;
+
+    /** 后台备注 */
+    @ApiModelProperty(value = "后台备注",required = false)
+    private String comment;
+
+    /** 创建时间 */
+    private java.util.Date createTime;
+
+    /** 修改时间 */
+    private java.util.Date updateTime;
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getTransNo() {
+        return transNo;
+    }
+
+    public void setTransNo(String transNo) {
+        this.transNo = transNo;
+    }
+
+    public PlatformCashAccountDetailTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(PlatformCashAccountDetailTypeEnum type) {
+        this.type = type;
+    }
+
+    public DealStatusEnum getStatus() {
+        return status;
+    }
+
+    public void setStatus(DealStatusEnum status) {
+        this.status = status;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    public BigDecimal getBalance() {
+        return balance;
+    }
+
+    public void setBalance(BigDecimal balance) {
+        this.balance = balance;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentRechargeQueryInfo.java

@@ -0,0 +1,12 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+
+/**
+ * @author : chengp
+ * @version V1.0
+ * @Description: TODO
+ * @date Date : 2019年09月24日 10:07
+ */
+public class StudentRechargeQueryInfo extends QueryInfo {
+}

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRechargeService.java

@@ -11,4 +11,6 @@ public interface StudentRechargeService extends BaseService<String, StudentRecha
      * @param rechargeDto
      */
     Boolean recharge(RechargeDto rechargeDto);
+
+    StudentRecharge selectByTransNo(String transNo);
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysUserCashAccountDetailService.java

@@ -5,4 +5,6 @@ import com.ym.mec.common.service.BaseService;
 
 public interface SysUserCashAccountDetailService extends BaseService<Long, SysUserCashAccountDetail> {
 
+    SysUserCashAccountDetail selectDetailByTransNo(String transNo);
+
 }

+ 10 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRechargeServiceImpl.java

@@ -40,17 +40,17 @@ public class StudentRechargeServiceImpl extends BaseServiceImpl<String, StudentR
 	@Override
 	public Boolean recharge(RechargeDto rechargeDto) {
 
-		//TODO ???????????????
+		//TODO 调用第三方支付
 		Date now  = new Date();
 
-		//?????????
+		//充值记录
         StudentRecharge studentRecharge = new StudentRecharge();
         studentRecharge.setAmount(rechargeDto.getRechargeAmount());
 		studentRecharge.setCreateTime(now);
 		studentRecharge.setUserId(rechargeDto.getUserId().longValue());
 		studentRecharge.setTransNo(null);
 		studentRechargeDao.insert(studentRecharge);
-		//??????
+		//账户资金流水
 		SysUserCashAccountDetail cashAccount = new SysUserCashAccountDetail();
 		cashAccount.setAmount(rechargeDto.getRechargeAmount());
 		cashAccount.setBalance(null);
@@ -59,9 +59,15 @@ public class StudentRechargeServiceImpl extends BaseServiceImpl<String, StudentR
 		cashAccount.setUserId(rechargeDto.getUserId());
 		cashAccount.setCreateTime(now);
 		sysUserCashAccountDetailDao.insert(cashAccount);
-		//??????????
+
+		//扣减账户
 		sysUserCashAccountDao.incrAccount(rechargeDto.getUserId(),rechargeDto.getRechargeAmount());
 
 		return true;
 	}
+
+	@Override
+	public StudentRecharge selectByTransNo(String transNo) {
+		return studentRechargeDao.selectByTransNo(transNo);
+	}
 }

+ 5 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserCashAccountDetailServiceImpl.java

@@ -19,5 +19,9 @@ public class SysUserCashAccountDetailServiceImpl extends BaseServiceImpl<Long, S
 	public BaseDAO<Long, SysUserCashAccountDetail> getDAO() {
 		return sysUserCashAccountDetailDao;
 	}
-	
+
+	@Override
+	public SysUserCashAccountDetail selectDetailByTransNo(String transNo) {
+		return sysUserCashAccountDetailDao.selectDetailByTransNo(transNo);
+	}
 }

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/StudentRechargeMapper.xml

@@ -97,4 +97,8 @@
     <select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM student_recharge
 	</select>
+
+    <select id="selectByTransNo" resultMap="StudentRecharge">
+		SELECT * FROM student_recharge WHERE  trans_no_ = #{transNo}
+	</select>
 </mapper>

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/SysUserCashAccountDetailMapper.xml

@@ -93,4 +93,8 @@
     <select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM sys_user_cash_account_detail
 	</select>
+
+    <select id="selectDetailByTransNo" resultMap="SysUserCashAccountDetail">
+		SELECT * FROM sys_user_cash_account_detail WHERE    trans_no_ = #{transNo}
+	</select>
 </mapper>

+ 81 - 0
mec-web/src/main/java/com/ym/mec/web/controller/student/StudentCashAccountDetailController.java

@@ -0,0 +1,81 @@
+package com.ym.mec.web.controller.student;
+import com.ym.mec.biz.dal.entity.StudentRecharge;
+import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.page.StudentCashDetailQueryInfo;
+import com.ym.mec.biz.service.StudentRechargeService;
+import com.ym.mec.biz.service.SysUserCashAccountDetailService;
+import com.ym.mec.common.controller.BaseController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+
+/**
+ * @version V1.0
+ * @Description: TODO
+ * @date Date : 2019年09月24日 10:00
+ */
+@RequestMapping("cashAccountDetail")
+@Api(tags = "学生充值")
+@RestController
+public class StudentCashAccountDetailController extends BaseController {
+
+
+    @Autowired
+    private SysUserCashAccountDetailService sysUserCashAccountDetailService;
+
+    @Autowired
+    private StudentRechargeService studentRechargeService;
+    @ApiOperation(value = "账户流水列表")
+    @GetMapping(value = "/queryPage",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    public Object queryPage(@RequestBody(required = false) StudentCashDetailQueryInfo queryInfo){
+        if(queryInfo == null){
+            queryInfo = new StudentCashDetailQueryInfo();
+        }
+        return succeed(sysUserCashAccountDetailService.queryPage(queryInfo));
+    }
+
+    /**
+     * 同步
+     * @return
+     */
+    @ApiOperation(value = "账户流水同步")
+    @GetMapping(value = "/synTransStatus",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    public Object synTransStatus(@RequestBody String transNo){
+
+        if(StringUtils.isEmpty(transNo)){
+            return failed();
+        }
+
+        //
+        StudentRecharge studentRecharge = studentRechargeService.selectByTransNo(transNo);
+        if(studentRecharge == null){
+            return failed("交易不存在");
+        }
+        SysUserCashAccountDetail sysUserCashAccountDetail = sysUserCashAccountDetailService.selectDetailByTransNo(transNo);
+        if(sysUserCashAccountDetail == null){
+            return failed("交易不存在");
+        }
+
+        //TODO 查询第三方
+
+        //更新充值记录
+        studentRecharge.setStatus(DealStatusEnum.ING);
+        studentRecharge.setModifyTime(new Date());
+        studentRechargeService.update(studentRecharge);
+
+        //更新流水记录
+        sysUserCashAccountDetail.setStatus(DealStatusEnum.ING);
+        sysUserCashAccountDetail.setUpdateTime(new Date());
+        sysUserCashAccountDetailService.update(sysUserCashAccountDetail);
+        return succeed();
+    }
+}