From db4e04451ea5e12e020675b794e586ad4298adb4 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 22 Feb 2018 18:32:22 +0800 Subject: [PATCH] bill --- .../appclient/web/RetailAppController.java | 26 +++++++-- .../payment/manage/bill/bean/NewBillBean.java | 29 ++++++++++ ...tionService.java => BillOrderService.java} | 2 +- .../payment/manage/bill/core/BillService.java | 16 +++++- ...iceImpl.java => BillOrderServiceImpl.java} | 17 +++--- .../bill/core/impl/BillServiceImpl.java | 56 ++++++++++++++----- .../manage/mappers/bill/BillMapper.java | 6 +- ...lationMapper.java => BillOrderMapper.java} | 9 +-- .../manage/mappers/bill/BillOrderMapper.xml | 14 +++++ .../manage/mappers/bill/BillOrderRelation.xml | 5 -- 10 files changed, 141 insertions(+), 39 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/bill/bean/NewBillBean.java rename src/main/java/au/com/royalpay/payment/manage/bill/core/{BillOrderRelationService.java => BillOrderService.java} (83%) rename src/main/java/au/com/royalpay/payment/manage/bill/core/impl/{BillOrderRelationServiceImpl.java => BillOrderServiceImpl.java} (53%) rename src/main/java/au/com/royalpay/payment/manage/mappers/bill/{BillOrderRelationMapper.java => BillOrderMapper.java} (78%) create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.xml delete mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelation.xml diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index c6fe94456..4bdda8e1a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -4,7 +4,9 @@ import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; -import au.com.royalpay.payment.manage.bill.core.BillOrderRelationService; +import au.com.royalpay.payment.manage.bill.bean.NewBillBean; +import au.com.royalpay.payment.manage.bill.core.BillOrderService; +import au.com.royalpay.payment.manage.bill.core.BillService; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; import au.com.royalpay.payment.tools.CommonConsts; @@ -41,7 +43,9 @@ public class RetailAppController { @Resource private SignInStatusManager signInStatusManager; @Resource - private BillOrderRelationService billOrderRelationService; + private BillOrderService billOrderService; + @Resource + private BillService billService; @RequestMapping(value = "/token", method = RequestMethod.PUT) public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) { @@ -282,8 +286,20 @@ public class RetailAppController { public JSONObject getAdDetail(@PathVariable String article_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { return retailAppService.getAdDetail(device,article_id); } - @RequestMapping(value = "/bill/{bill_id}") - public List getBills(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ - return billOrderRelationService.getByBillId(bill_id,device.getIntValue("client_id")); + @RequestMapping(value = "/bill/{bill_id}",method = RequestMethod.GET) + public JSONObject getBills(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ + return billService.getBillDetail(bill_id,device.getIntValue("client_id")); + } + @RequestMapping(value = "/bill",method = RequestMethod.PUT) + public void addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@RequestBody NewBillBean newBillBean){ + billService.save(device.getIntValue("client_id"),newBillBean); + } + @RequestMapping(value = "/bill/{bill_id}/close",method = RequestMethod.POST) + public void closeBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ + billService.updateBillStatus(bill_id,"2"); + } + @RequestMapping(value = "/bill/orders/{bill_id}/",method = RequestMethod.GET) + public List getBillOrders(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ + return billOrderService.getByBillId(bill_id,device.getIntValue("client_id")); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/bill/bean/NewBillBean.java b/src/main/java/au/com/royalpay/payment/manage/bill/bean/NewBillBean.java new file mode 100644 index 000000000..aa335bd35 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/bill/bean/NewBillBean.java @@ -0,0 +1,29 @@ +package au.com.royalpay.payment.manage.bill.bean; + +import java.math.BigDecimal; + +/** + * Created by wangning on 11/02/2018. + */ +public class NewBillBean { + + private BigDecimal amount; + + private String currency; + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/bill/core/BillOrderRelationService.java b/src/main/java/au/com/royalpay/payment/manage/bill/core/BillOrderService.java similarity index 83% rename from src/main/java/au/com/royalpay/payment/manage/bill/core/BillOrderRelationService.java rename to src/main/java/au/com/royalpay/payment/manage/bill/core/BillOrderService.java index 01cfad8b3..e7c4f609b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bill/core/BillOrderRelationService.java +++ b/src/main/java/au/com/royalpay/payment/manage/bill/core/BillOrderService.java @@ -7,7 +7,7 @@ import java.util.List; /** * Created by wangning on 11/02/2018. */ -public interface BillOrderRelationService { +public interface BillOrderService { List getByBillId(String bill_id, int client_id); } diff --git a/src/main/java/au/com/royalpay/payment/manage/bill/core/BillService.java b/src/main/java/au/com/royalpay/payment/manage/bill/core/BillService.java index e3bc53eac..a1d208bbf 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bill/core/BillService.java +++ b/src/main/java/au/com/royalpay/payment/manage/bill/core/BillService.java @@ -1,12 +1,24 @@ package au.com.royalpay.payment.manage.bill.core; -import com.google.gson.JsonObject; +import au.com.royalpay.payment.manage.bill.bean.NewBillBean; + +import com.alibaba.fastjson.JSONObject; + +import java.util.List; /** * Created by wangning on 11/02/2018. */ public interface BillService { - JsonObject getByBillId(String bill_id,int client_id); + JSONObject getBillDetail(String billId,int client_id); + + void updateBillStatus(String billId,String status); + + void removeBill(String billId); + + JSONObject save(int client_id,NewBillBean newBillBean); + + List getBills(int client_id); } diff --git a/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillOrderRelationServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillOrderServiceImpl.java similarity index 53% rename from src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillOrderRelationServiceImpl.java rename to src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillOrderServiceImpl.java index b6938fbf0..df54a18ad 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillOrderRelationServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillOrderServiceImpl.java @@ -4,24 +4,24 @@ import java.util.List; import javax.annotation.Resource; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import com.alibaba.fastjson.JSONObject; -import com.google.gson.JsonObject; - -import au.com.royalpay.payment.manage.bill.core.BillOrderRelationService; +import au.com.royalpay.payment.manage.bill.core.BillOrderService; import au.com.royalpay.payment.manage.mappers.bill.BillMapper; -import au.com.royalpay.payment.manage.mappers.bill.BillOrderRelationMapper; +import au.com.royalpay.payment.manage.mappers.bill.BillOrderMapper; +import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper; import au.com.royalpay.payment.tools.exceptions.BadRequestException; /** * Created by wangning on 11/02/2018. */ @Service -public class BillOrderRelationServiceImpl implements BillOrderRelationService { +public class BillOrderServiceImpl implements BillOrderService { @Resource - private BillOrderRelationMapper billOrderRelationMapper; + private BillOrderMapper billOrderMapper; @Resource private BillMapper billMapper; @Override @@ -30,6 +30,9 @@ public class BillOrderRelationServiceImpl implements BillOrderRelationService { if(bill.getIntValue("client_id")!= client_id){ throw new BadRequestException("You have no right to check this bill"); } - return billOrderRelationMapper.findByBillId(bill_id); + List wechatBillOrders = billOrderMapper.findByBillIdWithWechatInfo(bill_id); + List alipayBillOrders = billOrderMapper.findByBillIdWithAlipayInfo(bill_id); + wechatBillOrders.addAll(alipayBillOrders); + return wechatBillOrders; } } diff --git a/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillServiceImpl.java index 714fb5d6a..246365a4e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillServiceImpl.java @@ -1,19 +1,19 @@ package au.com.royalpay.payment.manage.bill.core.impl; -import com.google.gson.JsonObject; - -import au.com.royalpay.payment.manage.bill.core.BillService; -import au.com.royalpay.payment.manage.mappers.bill.BillMapper; -import au.com.royalpay.payment.manage.mappers.bill.BillOrderRelationMapper; -import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import java.util.Date; +import java.util.List; -import com.alibaba.fastjson.JSONObject; +import javax.annotation.Resource; import org.springframework.stereotype.Service; -import java.util.List; +import com.alibaba.fastjson.JSONObject; -import javax.annotation.Resource; +import au.com.royalpay.payment.manage.bill.bean.NewBillBean; +import au.com.royalpay.payment.manage.bill.core.BillService; +import au.com.royalpay.payment.manage.mappers.bill.BillMapper; +import au.com.royalpay.payment.manage.mappers.bill.BillOrderMapper; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; /** * Created by wangning on 11/02/2018. @@ -23,15 +23,43 @@ public class BillServiceImpl implements BillService { @Resource private BillMapper billMapper; @Resource - private BillOrderRelationMapper billOrderRelationMapper; + private BillOrderMapper billOrderMapper; + + @Override + public JSONObject save(int client_id,NewBillBean newBillBean) { + JSONObject record = new JSONObject(); + record.put("client_id",client_id); + record.put("amount",newBillBean.getAmount()); + record.put("currency",newBillBean.getCurrency()); + record.put("create_time", new Date()); + record.put("status", 1); + return billMapper.save(record); + } + + @Override + public List getBills(int client_id) { + return billMapper.findByClientId(client_id); + } @Override - public JsonObject getByBillId(String bill_id, int client_id) { - JSONObject bill = billMapper.findOne(bill_id); - if(bill.getIntValue("client_id")!= client_id){ + public JSONObject getBillDetail(String billId, int client_id) { + JSONObject bill = billMapper.findOne(billId); + if (bill.getIntValue("client_id") != client_id) { throw new BadRequestException("You have no right to check this bill"); } + return bill; + } + + @Override + public void updateBillStatus(String billId, String status) { + JSONObject record = new JSONObject(); + record.put("bill_id", billId); + record.put("status", status); + billMapper.update(record); + } - return null; + @Override + public void removeBill(String billId) { + billMapper.delete(billId); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillMapper.java index 9160e15a9..5a592f622 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillMapper.java @@ -1,5 +1,7 @@ package au.com.royalpay.payment.manage.mappers.bill; +import java.util.List; + import org.apache.ibatis.annotations.Param; import com.alibaba.fastjson.JSONObject; @@ -23,6 +25,8 @@ public interface BillMapper { int update(JSONObject record); @AutoSql(type = SqlType.SELECT) - JSONObject findByClientId(@Param("client_id") int client_id); + List findByClientId(@Param("client_id") int client_id); + @AutoSql(type = SqlType.DELETE) + void delete(@Param("bill_id") String billId); } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelationMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.java similarity index 78% rename from src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelationMapper.java rename to src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.java index d2dab9881..ef303cc23 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelationMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.java @@ -14,16 +14,17 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType; * Create by yixian at 2017-12-19 19:09 */ @AutoMapper(tablename = "pmt_bill_order_relation", pkName = "bill_id") -public interface BillOrderRelationMapper { +public interface BillOrderMapper { @AutoSql(type = SqlType.INSERT) JSONObject save(JSONObject record); - @AutoSql(type = SqlType.SELECT) - List findByBillId(@Param("bill_id") String bill_id); - @AutoSql(type = SqlType.UPDATE) int update(JSONObject record); + List findByBillIdWithWechatInfo(@Param("bill_id") String bill_id); + + List findByBillIdWithAlipayInfo(@Param("bill_id") String bill_id); + @AutoSql(type = SqlType.SELECT) JSONObject findByClientId(@Param("client_id") int client_id); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.xml new file mode 100644 index 000000000..b69621976 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelation.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelation.xml deleted file mode 100644 index 36580a4c3..000000000 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelation.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file