|  |  | 
 |  |  | 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.VoVcRecharge; | 
 |  |  | import com.dy.pipIrrGlobal.voSe.VoVirtualCard; | 
 |  |  |  | 
 |  |  | import com.dy.pipIrrSell.result.SellResultCode; | 
 |  |  | import com.dy.pipIrrSell.virtualCard.dto.DtoVcRecharge; | 
 |  |  | import com.dy.pipIrrSell.virtualCard.dto.DtoVirtualCard; | 
 |  |  | import com.dy.pipIrrSell.virtualCard.enums.LastOperateENUM; | 
 |  |  | import com.dy.pipIrrSell.virtualCard.enums.OrderStateENUM; | 
 |  |  |  | 
 |  |  | import com.dy.pipIrrWechat.virtualCard.dto.DtoVcRecharge; | 
 |  |  | 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 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; | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @author ZhuBaoMin | 
 |  |  |  * @date 2024-07-11 15:49 | 
 |  |  |  * @LastEditTime 2024-07-11 15:49 | 
 |  |  |  * @date 2024-07-15 9:39 | 
 |  |  |  * @LastEditTime 2024-07-15 9:39 | 
 |  |  |  * @Description | 
 |  |  |  */ | 
 |  |  |  | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private SeClientMapper seClientMapper; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private SeVcOperateMapper seVcOperateMapper; | 
 |  |  |  | 
 |  |  |     @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); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * 添加虚拟卡充值记录 | 
 |  |  |      * 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(); | 
 |  |  | 
 |  |  |  | 
 |  |  |         // 验证该虚拟卡账户是否存在并取出当前账户余额 | 
 |  |  |         SeVirtualCard seVirtualCard = seVirtualCardMapper.selectByPrimaryKey(virtualId); | 
 |  |  |  | 
 |  |  |         if(seVirtualCard == null) { | 
 |  |  |             return BaseResponseUtils.buildFail(SellResultCode.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(SellResultCode.RECHARGE_FAIL.getMessage()); | 
 |  |  |         seVcRechargeMapper.insert(seVcRecharge); | 
 |  |  |         Long rechargeId = seVcRecharge.getId(); | 
 |  |  |         if(rechargeId == null) { | 
 |  |  |             return 0L; | 
 |  |  |         } | 
 |  |  |         return BaseResponseUtils.buildSuccess(true) ; | 
 |  |  |         return rechargeId; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |     public BaseResponse<Boolean> updateVCRecharge(String orderNumber, Date rechargeTime) { | 
 |  |  |         SeVcRecharge seVcRecharge = seVcRechargeMapper.getVCRechargeByorderNumber(orderNumber); | 
 |  |  |         if(seVcRecharge == null) { | 
 |  |  |             return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_NOT_EXIST.getMessage()); | 
 |  |  |             return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_NOT_EXIST.getMessage()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         Long virtualId = seVcRecharge.getVcId(); | 
 |  |  | 
 |  |  |         seVcRecharge.setOrderState(OrderStateENUM.PAID.getCode()); | 
 |  |  |         Integer rec = seVcRechargeMapper.updateByPrimaryKeySelective(seVcRecharge); | 
 |  |  |         if(rec == null) { | 
 |  |  |             return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL.getMessage()); | 
 |  |  |             return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_FAIL.getMessage()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         SeVirtualCard seVirtualCard = seVirtualCardMapper.selectByPrimaryKey(virtualId); | 
 |  |  |         if(seVirtualCard == null) { | 
 |  |  |             return BaseResponseUtils.buildFail(SellResultCode.VIRTUAL_CARD_NOT_EXIST.getMessage()); | 
 |  |  |             return BaseResponseUtils.buildFail(WechatResultCode.VIRTUAL_CARD_NOT_EXIST.getMessage()); | 
 |  |  |         } | 
 |  |  |         seVirtualCard.setMoney(afterRrecharge); | 
 |  |  |         seVirtualCard.setLastOperate(LastOperateENUM.RECHARGE.getCode()); | 
 |  |  |         seVirtualCard.setLastOperateTime(new Date()); | 
 |  |  |         Integer rec2 = seVirtualCardMapper.updateByPrimaryKeySelective(seVirtualCard); | 
 |  |  |         if(rec2 == null) { | 
 |  |  |             return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL.getMessage()); | 
 |  |  |             return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_FAIL.getMessage()); | 
 |  |  |         } | 
 |  |  |         return BaseResponseUtils.buildSuccess(true) ; | 
 |  |  |     } | 
 |  |  | 
 |  |  |  | 
 |  |  |         return rsVo; | 
 |  |  |     } | 
 |  |  | } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 添加虚拟卡操作记录 | 
 |  |  |      * @param po | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public Long insertVcOperate(SeVcOperate po) { | 
 |  |  |         seVcOperateMapper.insert(po); | 
 |  |  |         return po.getId(); | 
 |  |  |     } | 
 |  |  | } |