From efd5d8d14daceeae885ecc3e7ac5be21079bea08 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Sun, 11 Feb 2018 15:43:38 +0800 Subject: [PATCH] bill init --- .../appclient/web/RetailAppController.java | 7 ++++ .../bill/core/BillOrderRelationService.java | 13 +++++++ .../payment/manage/bill/core/BillService.java | 12 ++++++ .../impl/BillOrderRelationServiceImpl.java | 35 ++++++++++++++++++ .../bill/core/impl/BillServiceImpl.java | 37 +++++++++++++++++++ .../manage/mappers/bill/BillMapper.java | 28 ++++++++++++++ .../mappers/bill/BillOrderRelationMapper.java | 30 +++++++++++++++ .../manage/mappers/bill/BillMapper.xml | 5 +++ .../manage/mappers/bill/BillOrderRelation.xml | 5 +++ 9 files changed, 172 insertions(+) create mode 100644 src/main/java/au/com/royalpay/payment/manage/bill/core/BillOrderRelationService.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/bill/core/BillService.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillOrderRelationServiceImpl.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillServiceImpl.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillMapper.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelationMapper.java create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillMapper.xml create 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 670682d8f..c6fe94456 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,6 +4,7 @@ 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.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; import au.com.royalpay.payment.tools.CommonConsts; @@ -39,6 +40,8 @@ public class RetailAppController { private RetailAppService retailAppService; @Resource private SignInStatusManager signInStatusManager; + @Resource + private BillOrderRelationService billOrderRelationService; @RequestMapping(value = "/token", method = RequestMethod.PUT) public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) { @@ -279,4 +282,8 @@ 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")); + } } 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/BillOrderRelationService.java new file mode 100644 index 000000000..01cfad8b3 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/bill/core/BillOrderRelationService.java @@ -0,0 +1,13 @@ +package au.com.royalpay.payment.manage.bill.core; + +import com.alibaba.fastjson.JSONObject; + +import java.util.List; + +/** + * Created by wangning on 11/02/2018. + */ +public interface BillOrderRelationService { + + 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 new file mode 100644 index 000000000..e3bc53eac --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/bill/core/BillService.java @@ -0,0 +1,12 @@ +package au.com.royalpay.payment.manage.bill.core; + +import com.google.gson.JsonObject; + +/** + * Created by wangning on 11/02/2018. + */ +public interface BillService { + + JsonObject getByBillId(String bill_id,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/BillOrderRelationServiceImpl.java new file mode 100644 index 000000000..b6938fbf0 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillOrderRelationServiceImpl.java @@ -0,0 +1,35 @@ +package au.com.royalpay.payment.manage.bill.core.impl; + +import java.util.List; + +import javax.annotation.Resource; + +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.mappers.bill.BillMapper; +import au.com.royalpay.payment.manage.mappers.bill.BillOrderRelationMapper; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; + +/** + * Created by wangning on 11/02/2018. + */ +@Service +public class BillOrderRelationServiceImpl implements BillOrderRelationService { + @Resource + private BillOrderRelationMapper billOrderRelationMapper; + @Resource + private BillMapper billMapper; + @Override + public List getByBillId(String bill_id, int client_id) { + JSONObject bill = billMapper.findOne(bill_id); + if(bill.getIntValue("client_id")!= client_id){ + throw new BadRequestException("You have no right to check this bill"); + } + return billOrderRelationMapper.findByBillId(bill_id); + } +} 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 new file mode 100644 index 000000000..714fb5d6a --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/bill/core/impl/BillServiceImpl.java @@ -0,0 +1,37 @@ +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 com.alibaba.fastjson.JSONObject; + +import org.springframework.stereotype.Service; + +import java.util.List; + +import javax.annotation.Resource; + +/** + * Created by wangning on 11/02/2018. + */ +@Service +public class BillServiceImpl implements BillService { + @Resource + private BillMapper billMapper; + @Resource + private BillOrderRelationMapper billOrderRelationMapper; + + @Override + public JsonObject getByBillId(String bill_id, int client_id) { + JSONObject bill = billMapper.findOne(bill_id); + if(bill.getIntValue("client_id")!= client_id){ + throw new BadRequestException("You have no right to check this bill"); + } + + return null; + } +} 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 new file mode 100644 index 000000000..9160e15a9 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillMapper.java @@ -0,0 +1,28 @@ +package au.com.royalpay.payment.manage.mappers.bill; + +import org.apache.ibatis.annotations.Param; + +import com.alibaba.fastjson.JSONObject; + +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; + +/** + * Create by yixian at 2017-12-19 19:09 + */ +@AutoMapper(tablename = "pmt_bill", pkName = "bill_id") +public interface BillMapper { + @AutoSql(type = SqlType.INSERT) + JSONObject save(JSONObject record); + + @AutoSql(type = SqlType.SELECT) + JSONObject findOne(@Param("bill_id") String bill_id); + + @AutoSql(type = SqlType.UPDATE) + int update(JSONObject record); + + @AutoSql(type = SqlType.SELECT) + JSONObject findByClientId(@Param("client_id") int client_id); + +} 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/BillOrderRelationMapper.java new file mode 100644 index 000000000..d2dab9881 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelationMapper.java @@ -0,0 +1,30 @@ +package au.com.royalpay.payment.manage.mappers.bill; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.alibaba.fastjson.JSONObject; + +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +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 { + @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); + + @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/BillMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillMapper.xml new file mode 100644 index 000000000..905e3a3ad --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillMapper.xml @@ -0,0 +1,5 @@ + + + + + \ 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 new file mode 100644 index 000000000..36580a4c3 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/bill/BillOrderRelation.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file