|  |  |  | 
|---|
|  |  |  | import com.dy.common.aop.SsoAop; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voSe.VoTermActiveCard; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voSe.VoTermCommon; | 
|---|
|  |  |  | import com.dy.common.webUtil.QueryResultVo; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voSe.*; | 
|---|
|  |  |  | import com.dy.pipIrrTerminal.card.dto.*; | 
|---|
|  |  |  | import jakarta.validation.Valid; | 
|---|
|  |  |  | import lombok.RequiredArgsConstructor; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.http.MediaType; | 
|---|
|  |  |  | import org.springframework.validation.BindingResult; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 开卡(含充值) | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = cardSv.activeOrReissueTermCard(po); | 
|---|
|  |  |  | if(map_result.get("success").equals(false)) { | 
|---|
|  |  |  | if (map_result.get("success").equals(false)) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 充值 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = cardSv.addRecharge(po, null); | 
|---|
|  |  |  | if(map_result.get("success").equals(false)) { | 
|---|
|  |  |  | if (map_result.get("success").equals(false)) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 挂失 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = cardSv.reportLoss(po); | 
|---|
|  |  |  | if(map_result.get("success").equals(false)) { | 
|---|
|  |  |  | if (map_result.get("success").equals(false)) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 解锁 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = cardSv.unlock(po); | 
|---|
|  |  |  | if(map_result.get("success").equals(false)) { | 
|---|
|  |  |  | if (map_result.get("success").equals(false)) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 补卡 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = cardSv.reissue(po); | 
|---|
|  |  |  | if(map_result.get("success").equals(false)) { | 
|---|
|  |  |  | if (map_result.get("success").equals(false)) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 销卡 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = cardSv.cancel(po); | 
|---|
|  |  |  | if(map_result.get("success").equals(false)) { | 
|---|
|  |  |  | if (map_result.get("success").equals(false)) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 补扣 | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping(path = "termRepay", consumes = MediaType.APPLICATION_JSON_VALUE) | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<VoRepaySupplement> termRepay(@RequestBody @Valid DtoRepaySupplement po, BindingResult bindingResult) { | 
|---|
|  |  |  | if (bindingResult != null && bindingResult.hasErrors()) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(po.getRepayMorny()  == null || po.getRepayMorny() <= 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("补扣金额不能为空且需大于0"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(po.getRepayMorny() > po.getBalance()) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("补扣金额不能大于补扣前余额"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = cardSv.repay(po); | 
|---|
|  |  |  | if (map_result.get("success").equals(false)) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 返还 | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping(path = "supplement", consumes = MediaType.APPLICATION_JSON_VALUE) | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<VoRepaySupplement> supplement(@RequestBody @Valid DtoRepaySupplement po, BindingResult bindingResult) { | 
|---|
|  |  |  | if (bindingResult != null && bindingResult.hasErrors()) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(po.getSupplementMoney() == null || po.getSupplementMoney() <= 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("返还金额不能为空且需大于0"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = cardSv.supplement(po); | 
|---|
|  |  |  | if (map_result.get("success").equals(false)) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 操作执行回调 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = cardSv.callBack(po); | 
|---|
|  |  |  | if(map_result.get("success").equals(false)) { | 
|---|
|  |  |  | if (map_result.get("success").equals(false)) { | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(map_result.get("content")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 读取卡信息 | 
|---|
|  |  |  | * @param cardAddr | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping(path = "readCard") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<VoTermCard> readCard(@RequestParam String cardAddr){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | VoTermCard voTermCard = cardSv.readCard(cardAddr); | 
|---|
|  |  |  | if(voTermCard == null) { | 
|---|
|  |  |  | return BaseResponseUtils.buildNonExist(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(voTermCard); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("查询农户异常", e); | 
|---|
|  |  |  | return BaseResponseUtils.buildException(e.getMessage()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|