parent
f84526df5d
commit
a628f0af79
10 changed files with 262 additions and 2 deletions
@ -0,0 +1,71 @@ |
||||
package com.ynxbd.common.dao.peis; |
||||
|
||||
import com.ynxbd.common.bean.pay.PayCasebook; |
||||
import com.ynxbd.common.bean.pay.Recipe; |
||||
import com.ynxbd.common.bean.record.Record; |
||||
import com.ynxbd.common.config.db.DataBase; |
||||
|
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* @author 李进才 |
||||
* @ClassName PeisDao |
||||
* @Description TODO |
||||
* @date 2023/11/16 15:43:00 |
||||
*/ |
||||
public class PeisDao { |
||||
/** |
||||
* 处方支付,数据预存(单个) |
||||
* |
||||
* @param recipe 支付信息 |
||||
* @return 是否存储成功 |
||||
*/ |
||||
public boolean insert(Recipe recipe) { |
||||
String sql = "insert into peis_reserve(updateTime, peisStatus, payStatus, openId, patientId, payMoney, totalFee, outTradeNo, recipeId, treatNum) values (now(),?,?,?,?,?,?,?,?,?)"; |
||||
return DataBase.insert(sql, ps -> { |
||||
ps.setInt(1, recipe.getPeisStatus()); |
||||
ps.setInt(2, recipe.getPayStatus()); |
||||
ps.setString(3, recipe.getOpenid()); |
||||
ps.setString(4, recipe.getPatientId()); |
||||
ps.setBigDecimal(5, recipe.getTotalFee()); |
||||
ps.setBigDecimal(6,recipe.getPayMoney()); |
||||
//
|
||||
ps.setString(7, recipe.getOutTradeNo()); |
||||
ps.setString(8, recipe.getRecipeId()); |
||||
ps.setString(9, recipe.getTreatNum()); |
||||
|
||||
}) > 0; |
||||
} |
||||
|
||||
/** |
||||
* 判断该处方是否重复计费 |
||||
* @param recipeId 处方号 |
||||
* @return |
||||
*/ |
||||
public boolean isRepeat(String recipeId){ |
||||
String sql = "select * from peis_reserve where recipeId = ? and peisStatus = 0"; |
||||
return !DataBase.select(sql,Recipe.class,ps->{ |
||||
ps.setString(1,recipeId); |
||||
}).isEmpty(); |
||||
} |
||||
|
||||
public Recipe selectByOutTradeNo(String outTradeNo) { |
||||
String sql = "select * from peis_reserve where outTradeNo=? order by updateTime desc"; |
||||
List<Recipe> list = DataBase.select(sql, Recipe.class, ps -> { |
||||
ps.setString(1, outTradeNo); |
||||
}); |
||||
if (list.size() > 0) { |
||||
return list.get(0); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public boolean updatePayStateOk(String outTradeNo, String bankTransNo) { |
||||
String sql = "update peis_reserve set payStatus=0, bankTransNo=? where outTradeNo=? and bankTransNo is null"; |
||||
return DataBase.update(sql, ps -> { |
||||
ps.setString(1, bankTransNo); |
||||
ps.setString(2, outTradeNo); |
||||
}) > 0; |
||||
} |
||||
} |
@ -0,0 +1,50 @@ |
||||
package com.ynxbd.common.service; |
||||
|
||||
import com.ynxbd.common.bean.pay.Recipe; |
||||
import com.ynxbd.common.dao.peis.PeisDao; |
||||
import com.ynxbd.common.result.Result; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @author 李进才 |
||||
* @ClassName PeisService |
||||
* @Description TODO |
||||
* @date 2023/11/16 15:53:00 |
||||
*/ |
||||
|
||||
@Slf4j |
||||
public class PeisService { |
||||
|
||||
public Boolean Reserve(String openid, String patientId, String treatNum, String outTradeNo, String totalFee,String recipeId){ |
||||
Recipe recipe = new Recipe(); |
||||
recipe.setOpenid(openid); |
||||
recipe.setPatientId(patientId); |
||||
recipe.setTreatNum(treatNum); |
||||
recipe.setOutTradeNo(outTradeNo); |
||||
recipe.setRecipeId(recipeId); |
||||
recipe.setTotalFee(new BigDecimal(totalFee)); |
||||
recipe.setPayMoney(new BigDecimal(totalFee)); |
||||
recipe.setPeisStatus(-1); |
||||
recipe.setPayStatus(-1); |
||||
if(new PeisDao().isRepeat(recipe.getRecipeId())){ |
||||
log.info("[体检预约]该处方号已经缴费,recipeId-{}",recipe.getRecipeId()); |
||||
return false; |
||||
} |
||||
return new PeisDao().insert(recipe); |
||||
} |
||||
public void payNotify(String outTradeNo, String bankTransNo){ |
||||
PeisDao peisDao = new PeisDao(); |
||||
Recipe recipe = peisDao.selectByOutTradeNo(outTradeNo); |
||||
String recipeId = recipe.getRecipeId(); |
||||
Integer payStates = recipe.getPayStatus(); |
||||
if (payStates == 0) { |
||||
log.error("[体检预约]订单已支付 outTradeNo={}, bankTransNo={}, recipeId={}", outTradeNo, bankTransNo, recipeId); |
||||
return; |
||||
} |
||||
if (!peisDao.updatePayStateOk(outTradeNo, bankTransNo)) { |
||||
log.info("[体检预约]修改支付状态失败 outTradeNo={}, bankTransNo={}", outTradeNo, bankTransNo); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue