|
@@ -0,0 +1,157 @@
|
|
|
+package com.pj.tb_wallet_record;
|
|
|
+
|
|
|
+
|
|
|
+import com.pj.current.dto.APPLoginUserInfo;
|
|
|
+import com.pj.current.satoken.StpAPPUserUtil;
|
|
|
+import com.pj.enummj.DeleteStatus;
|
|
|
+import com.pj.tb_order.TbOrder;
|
|
|
+import com.pj.tb_people.TbPeople;
|
|
|
+import com.pj.tb_people.TbPeopleService;
|
|
|
+import com.pj.tb_wallet_record.vo.WalletRecordAppVo;
|
|
|
+import com.pj.tb_wallet_topdown.TbWalletTopdown;
|
|
|
+import com.pj.tb_wallet_topdown.TbWalletTopdownService;
|
|
|
+import com.pj.tb_wallet_topup.TbWalletTopup;
|
|
|
+import com.pj.tb_wallet_topup.TbWalletTopupService;
|
|
|
+import com.pj.utils.sg.AjaxJson;
|
|
|
+import com.pj.utils.so.SoMap;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Controller: tb_wallet_record -- 服务点交易记录
|
|
|
+ * @author plj
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/app/WalletManage/")
|
|
|
+public class TbWalletAppController {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 底层 Service 对象
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ TbWalletRecordService tbWalletRecordService;
|
|
|
+
|
|
|
+ /** 底层 Service 对象 */
|
|
|
+ @Autowired
|
|
|
+ TbWalletTopupService tbWalletTopupService;
|
|
|
+
|
|
|
+ /** 底层 Service 对象 */
|
|
|
+ @Autowired
|
|
|
+ TbWalletTopdownService tbWalletTopdownService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 底层 Service 对象
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ TbPeopleService tbPeopleService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查集合 - 根据条件(参数为空时代表忽略指定条件)
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("getList")
|
|
|
+ public AjaxJson getList() {
|
|
|
+ SoMap so = SoMap.getRequestSoMap();
|
|
|
+ if(StpAPPUserUtil.getAPPLoginInfo().getUserType() == 1){
|
|
|
+ List<WalletRecordAppVo> list = tbWalletRecordService.getAPPList(so.startPage());
|
|
|
+ if (list.size() == 0) return AjaxJson.getSuccess("暂无更多的订单消息!");
|
|
|
+ return AjaxJson.getPageData(so.getDataCount(), list);
|
|
|
+ }else{
|
|
|
+ return AjaxJson.getError("边民用户才能查看服务点交易记录!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /** 查服务点充值 - 根据id */
|
|
|
+ @RequestMapping("getTopUpById")
|
|
|
+ public AjaxJson getTopUpById(Long id){
|
|
|
+ TbWalletTopup t = tbWalletTopupService.getById(id);
|
|
|
+ return AjaxJson.getSuccessData(t);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /** 查服务点提现- 根据id */
|
|
|
+ @RequestMapping("getTopDownById")
|
|
|
+ public AjaxJson getTopDownById(Long id){
|
|
|
+ TbWalletTopdown t = tbWalletTopdownService.getById(id);
|
|
|
+ return AjaxJson.getSuccessData(t);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /** 查服务点扣除 - 根据id */
|
|
|
+ @RequestMapping("getWalletRecordById")
|
|
|
+ public AjaxJson getWalletRecordById(Long id){
|
|
|
+ TbWalletRecord t = tbWalletRecordService.getById(id);
|
|
|
+ return AjaxJson.getSuccessData(t);
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 服务点提现
|
|
|
+ */
|
|
|
+ @RequestMapping("topupSave")
|
|
|
+ public AjaxJson topupSave(@RequestParam("amount") Integer amount,@RequestParam("outTradeNo")String outTradeNo,@RequestParam("transactionId") String transactionId) {
|
|
|
+ //获取登录人
|
|
|
+ APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
+ TbWalletTopup tbWalletTopup = new TbWalletTopup();
|
|
|
+ Date date = new Date();
|
|
|
+ tbWalletTopup.setMchid("AAAAAA1111111111AAAAAA");
|
|
|
+ tbWalletTopup.setOutTradeNo(outTradeNo);
|
|
|
+ tbWalletTopup.setAmount(String.valueOf(amount/100));
|
|
|
+ tbWalletTopup.setTransactionId(transactionId);
|
|
|
+ tbWalletTopup.setPeopleId(appLoginInfo.getFk().toString());
|
|
|
+ tbWalletTopup.setTopupTime(date);
|
|
|
+ tbWalletTopup.setCreateTime(date);
|
|
|
+ tbWalletTopup.setCreateBy(appLoginInfo.getLoginId().toString());
|
|
|
+ tbWalletTopup.setCreateName(appLoginInfo.getLoginName());
|
|
|
+ tbWalletTopup.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
|
|
|
+ boolean ret=tbWalletTopupService.save(tbWalletTopup);
|
|
|
+ if(ret){
|
|
|
+ TbPeople tbPeople = tbPeopleService.getById(appLoginInfo.getFk());
|
|
|
+ tbPeople.setWallet(tbPeople.getWallet()+amount/100);
|
|
|
+ tbPeopleService.updateById(tbPeople);
|
|
|
+ return AjaxJson.getSuccess();
|
|
|
+ }else{
|
|
|
+ return AjaxJson.getError("操作失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 服务点提现
|
|
|
+ */
|
|
|
+ @RequestMapping("topdownSave")
|
|
|
+ public AjaxJson topdownSave(@RequestParam("amount") Integer amount,@RequestParam("outTradeNo")String outTradeNo,@RequestParam("transactionId") String transactionId) {
|
|
|
+ //获取登录人
|
|
|
+ APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
+ TbPeople tbPeople = tbPeopleService.getById(appLoginInfo.getFk());
|
|
|
+ if(tbPeople.getWallet()<amount/100){
|
|
|
+ return AjaxJson.getError("余额不足!");
|
|
|
+ }
|
|
|
+ TbWalletTopdown tbWalletTopdown = new TbWalletTopdown();
|
|
|
+ Date date = new Date();
|
|
|
+ tbWalletTopdown.setMchid("AAAAAA1111111111AAAAAA");
|
|
|
+ tbWalletTopdown.setOutTradeNo(outTradeNo);
|
|
|
+ tbWalletTopdown.setAmount(String.valueOf(amount/100));
|
|
|
+ tbWalletTopdown.setTransactionId(transactionId);
|
|
|
+ tbWalletTopdown.setPeopleId(appLoginInfo.getFk().toString());
|
|
|
+ tbWalletTopdown.setTopdownTime(date);
|
|
|
+ tbWalletTopdown.setCreateTime(date);
|
|
|
+ tbWalletTopdown.setCreateBy(appLoginInfo.getLoginId().toString());
|
|
|
+ tbWalletTopdown.setCreateName(appLoginInfo.getLoginName());
|
|
|
+ tbWalletTopdown.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
|
|
|
+ boolean ret=tbWalletTopdownService.save(tbWalletTopdown);
|
|
|
+ if(ret){
|
|
|
+ tbPeople.setWallet(tbPeople.getWallet()-amount/100);
|
|
|
+ tbPeopleService.updateById(tbPeople);
|
|
|
+ return AjaxJson.getSuccess();
|
|
|
+ }else{
|
|
|
+ return AjaxJson.getError("操作失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|