|
@ -1342,4 +1342,52 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 商城积分支付
|
|
|
* @param patient
|
|
|
* @param total
|
|
|
* @param hospital
|
|
|
* @param hospitalName
|
|
|
* @param array
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public MixEnvelop<CreditsDetailDO,CreditsDetailDO> payIntegrate(String patient,Double total,String hospital,String hospitalName,JSONArray array) throws Exception {
|
|
|
MixEnvelop<CreditsDetailDO,CreditsDetailDO> envelop = new MixEnvelop<>();
|
|
|
AccountDO accountDO = accountDao.selectByPatientId(patient);
|
|
|
Integer total1 = total.intValue();
|
|
|
if (accountDO == null){
|
|
|
envelop.setMessage("银行账户不存在!");
|
|
|
throw new Exception("银行账户不存在!");
|
|
|
}else {
|
|
|
if (total1>accountDO.getTotal()){
|
|
|
envelop.setMessage("积分余额不足!");
|
|
|
throw new Exception("积分余额不足!");
|
|
|
}else{
|
|
|
for (int i=0;i<array.size();i++){
|
|
|
JSONObject object = array.getJSONObject(i);
|
|
|
CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
|
|
|
creditsDetailDO.setPatientId(patient);
|
|
|
creditsDetailDO.setAccountId(accountDO.getId());
|
|
|
creditsDetailDO.setHospital(hospital);
|
|
|
creditsDetailDO.setTradeType("SHOPPING_PAY");
|
|
|
creditsDetailDO.setTradeDirection(-1);
|
|
|
creditsDetailDO.setTransactionId(object.getString("orderId"));
|
|
|
creditsDetailDO.setIntegrate(object.getDouble("integrate").intValue());
|
|
|
creditsDetailDO.setCreateTime(new Date());
|
|
|
creditsDetailDO.setUpdateTime(new Date());
|
|
|
creditsDetailDO.setSaasId("dev");
|
|
|
creditsDetailDO.setId(getCode());
|
|
|
creditsDetailDO.setCoupon(0);
|
|
|
creditsDetailDO.setStatus(1);
|
|
|
credittsLogDetailDao.save(creditsDetailDO);
|
|
|
}
|
|
|
accountDO.setTotal(accountDO.getTotal()-total1);
|
|
|
accountDao.save(accountDO);
|
|
|
}
|
|
|
}
|
|
|
return envelop;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|