| | |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoSe.*; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVcRecharge; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVcRefund; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVcRefundItem; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; |
| | | import com.dy.pipIrrGlobal.pojoSe.*; |
| | | import com.dy.pipIrrGlobal.voSe.VoOrders; |
| | | import com.dy.pipIrrGlobal.voSe.VoRechargeProfile; |
| | | import com.dy.pipIrrGlobal.voSe.VoVcRecharge; |
| | | import com.dy.pipIrrGlobal.voSe.VoVirtualCard; |
| | | import com.dy.pipIrrWechat.virtualCard.dto.DtoVcRecharge; |
| | | import com.dy.pipIrrWechat.result.WechatResultCode; |
| | | import com.dy.pipIrrWechat.virtualCard.dto.DtoVirtualCard; |
| | | import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM; |
| | | import com.dy.pipIrrWechat.virtualCard.enums.OrderStateENUM; |
| | | import com.dy.pipIrrWechat.result.WechatResultCode; |
| | | import com.dy.pipIrrWechat.virtualCard.qo.QoVcRecharge; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | @Autowired |
| | | private SeClientMapper seClientMapper; |
| | | |
| | | @Autowired |
| | | private SeVcOperateMapper seVcOperateMapper; |
| | | |
| | | @Autowired |
| | | private SeRechargeProfileMapper seRechargeProfileMapper; |
| | | |
| | | @Value("${vc.alarmValue}") |
| | | private Integer alarmValue; |
| | | |
| | | /** |
| | | * 根据农户ID获取5级行政区划代码,注册虚拟卡使用 |
| | | * @param clientId 农户ID |
| | |
| | | * @return |
| | | */ |
| | | public List<VoVirtualCard> getVCs(Long clientId) { |
| | | return seVirtualCardMapper.getVCs(clientId); |
| | | return seVirtualCardMapper.getVCs(alarmValue, clientId); |
| | | } |
| | | |
| | | /** |
| | |
| | | public Long insertVirtualCard(SeVirtualCard po) { |
| | | seVirtualCardMapper.insert(po); |
| | | return po.getId(); |
| | | } |
| | | |
| | | /** |
| | | * 根据农户ID及虚拟卡ID获取正常状态的虚拟卡对象 |
| | | * @param clientId |
| | | * @param vcId |
| | | * @return |
| | | */ |
| | | public SeVirtualCard getVcByClientIdAndVcId (Long clientId, Long vcId) { |
| | | return seVirtualCardMapper.getVcByClientIdAndVcId(clientId, vcId); |
| | | } |
| | | |
| | | /** |
| | | * 根据虚拟卡ID注销虚拟卡 |
| | | * @param clientId |
| | | * @param vcId |
| | | * @return |
| | | */ |
| | | public Integer cancelVc(Long clientId, Long vcId) { |
| | | return seVirtualCardMapper.cancelVc(clientId, vcId); |
| | | } |
| | | |
| | | /** |
| | |
| | | * 添加虚拟卡充值记录 |
| | | * JSAPI下单后生成部分充值记录 |
| | | * @param po |
| | | * @return |
| | | * @return -1:虚拟卡不存在,0:添加充值记录失败 |
| | | */ |
| | | public BaseResponse<Boolean> insertVCRecharge(DtoVirtualCard po) { |
| | | //public BaseResponse<Boolean> insertVCRecharge(DtoVirtualCard po) { |
| | | public Long insertVCRecharge(DtoVirtualCard po) { |
| | | String orderNumber = po.getOrderNumber(); |
| | | Long virtualId = po.getVirtualId(); |
| | | Long clientId = po.getClientId(); |
| | | Integer rechargeAmount = po.getRechargeAmount(); |
| | | Double rechargeAmount = po.getRechargeAmount(); |
| | | |
| | | // 验证该虚拟卡账户是否存在并取出当前账户余额 |
| | | SeVirtualCard seVirtualCard = seVirtualCardMapper.selectByPrimaryKey(virtualId); |
| | | |
| | | if(seVirtualCard == null) { |
| | | return BaseResponseUtils.buildFail(WechatResultCode.NO_ACCOUNT.getMessage()); |
| | | return -1L; |
| | | } |
| | | Double money = seVirtualCard.getMoney(); |
| | | |
| | |
| | | seVcRecharge.setRechargeAmount(rechargeAmount); |
| | | seVcRecharge.setOrderTime(new Date()); |
| | | seVcRecharge.setOrderState(OrderStateENUM.NON_PAYMENT.getCode()); |
| | | Integer rec = seVcRechargeMapper.insert(seVcRecharge); |
| | | if(rec == null) { |
| | | return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_FAIL.getMessage()); |
| | | seVcRechargeMapper.insert(seVcRecharge); |
| | | Long rechargeId = seVcRecharge.getId(); |
| | | if(rechargeId == null) { |
| | | return 0L; |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | return rechargeId; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | Long virtualId = seVcRecharge.getVcId(); |
| | | Double money = seVcRecharge.getMoney(); |
| | | Integer rechargeAmount = seVcRecharge.getRechargeAmount(); |
| | | Double rechargeAmount = seVcRecharge.getRechargeAmount(); |
| | | Double afterRrecharge = money + rechargeAmount; |
| | | |
| | | seVcRecharge.setAfterRecharge(afterRrecharge); |
| | |
| | | * @param orderNumber |
| | | * @return |
| | | */ |
| | | public Integer getRechargeAmountByOrderNumber(String orderNumber) { |
| | | public Double getRechargeAmountByOrderNumber(String orderNumber) { |
| | | return seVcRechargeMapper.getRechargeAmountByOrderNumber(orderNumber); |
| | | |
| | | } |
| | |
| | | * @param dtoVcRecharge |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoVcRecharge>> getVcRechargeRecords(DtoVcRecharge dtoVcRecharge){ |
| | | public QueryResultVo<List<VoVcRecharge>> getVcRechargeRecords(QoVcRecharge dtoVcRecharge){ |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(dtoVcRecharge); |
| | | Long itemTotal = seVirtualCardMapper.getRechargeRecordCount(params); |
| | | |
| | |
| | | |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 添加虚拟卡操作记录 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Long insertVcOperate(SeVcOperate po) { |
| | | seVcOperateMapper.insert(po); |
| | | return po.getId(); |
| | | } |
| | | |
| | | /** |
| | | * 获取虚拟卡常用充值金额配置 |
| | | * @return |
| | | */ |
| | | public List<VoRechargeProfile> gerRechargeProfiles() { |
| | | return seRechargeProfileMapper.gerRechargeProfiles(); |
| | | } |
| | | } |