master
wangning 7 years ago
parent efd5d8d14d
commit db4e04451e

@ -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.AppClientBean;
import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService; 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.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
@ -41,7 +43,9 @@ public class RetailAppController {
@Resource @Resource
private SignInStatusManager signInStatusManager; private SignInStatusManager signInStatusManager;
@Resource @Resource
private BillOrderRelationService billOrderRelationService; private BillOrderService billOrderService;
@Resource
private BillService billService;
@RequestMapping(value = "/token", method = RequestMethod.PUT) @RequestMapping(value = "/token", method = RequestMethod.PUT)
public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) { 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) { public JSONObject getAdDetail(@PathVariable String article_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.getAdDetail(device,article_id); return retailAppService.getAdDetail(device,article_id);
} }
@RequestMapping(value = "/bill/{bill_id}") @RequestMapping(value = "/bill/{bill_id}",method = RequestMethod.GET)
public List<JSONObject> getBills(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ public JSONObject getBills(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
return billOrderRelationService.getByBillId(bill_id,device.getIntValue("client_id")); 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<JSONObject> getBillOrders(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
return billOrderService.getByBillId(bill_id,device.getIntValue("client_id"));
} }
} }

@ -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;
}
}

@ -7,7 +7,7 @@ import java.util.List;
/** /**
* Created by wangning on 11/02/2018. * Created by wangning on 11/02/2018.
*/ */
public interface BillOrderRelationService { public interface BillOrderService {
List<JSONObject> getByBillId(String bill_id, int client_id); List<JSONObject> getByBillId(String bill_id, int client_id);
} }

@ -1,12 +1,24 @@
package au.com.royalpay.payment.manage.bill.core; 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. * Created by wangning on 11/02/2018.
*/ */
public interface BillService { 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<JSONObject> getBills(int client_id);
} }

@ -4,24 +4,24 @@ import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject; import au.com.royalpay.payment.manage.bill.core.BillOrderService;
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.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; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
/** /**
* Created by wangning on 11/02/2018. * Created by wangning on 11/02/2018.
*/ */
@Service @Service
public class BillOrderRelationServiceImpl implements BillOrderRelationService { public class BillOrderServiceImpl implements BillOrderService {
@Resource @Resource
private BillOrderRelationMapper billOrderRelationMapper; private BillOrderMapper billOrderMapper;
@Resource @Resource
private BillMapper billMapper; private BillMapper billMapper;
@Override @Override
@ -30,6 +30,9 @@ public class BillOrderRelationServiceImpl implements BillOrderRelationService {
if(bill.getIntValue("client_id")!= client_id){ if(bill.getIntValue("client_id")!= client_id){
throw new BadRequestException("You have no right to check this bill"); throw new BadRequestException("You have no right to check this bill");
} }
return billOrderRelationMapper.findByBillId(bill_id); List<JSONObject> wechatBillOrders = billOrderMapper.findByBillIdWithWechatInfo(bill_id);
List<JSONObject> alipayBillOrders = billOrderMapper.findByBillIdWithAlipayInfo(bill_id);
wechatBillOrders.addAll(alipayBillOrders);
return wechatBillOrders;
} }
} }

@ -1,19 +1,19 @@
package au.com.royalpay.payment.manage.bill.core.impl; package au.com.royalpay.payment.manage.bill.core.impl;
import com.google.gson.JsonObject; import java.util.Date;
import java.util.List;
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 javax.annotation.Resource;
import org.springframework.stereotype.Service; 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. * Created by wangning on 11/02/2018.
@ -23,15 +23,43 @@ public class BillServiceImpl implements BillService {
@Resource @Resource
private BillMapper billMapper; private BillMapper billMapper;
@Resource @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<JSONObject> getBills(int client_id) {
return billMapper.findByClientId(client_id);
}
@Override @Override
public JsonObject getByBillId(String bill_id, int client_id) { public JSONObject getBillDetail(String billId, int client_id) {
JSONObject bill = billMapper.findOne(bill_id); JSONObject bill = billMapper.findOne(billId);
if (bill.getIntValue("client_id") != client_id) { if (bill.getIntValue("client_id") != client_id) {
throw new BadRequestException("You have no right to check this bill"); 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);
} }
} }

@ -1,5 +1,7 @@
package au.com.royalpay.payment.manage.mappers.bill; package au.com.royalpay.payment.manage.mappers.bill;
import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -23,6 +25,8 @@ public interface BillMapper {
int update(JSONObject record); int update(JSONObject record);
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
JSONObject findByClientId(@Param("client_id") int client_id); List<JSONObject> findByClientId(@Param("client_id") int client_id);
@AutoSql(type = SqlType.DELETE)
void delete(@Param("bill_id") String billId);
} }

@ -14,16 +14,17 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
* Create by yixian at 2017-12-19 19:09 * Create by yixian at 2017-12-19 19:09
*/ */
@AutoMapper(tablename = "pmt_bill_order_relation", pkName = "bill_id") @AutoMapper(tablename = "pmt_bill_order_relation", pkName = "bill_id")
public interface BillOrderRelationMapper { public interface BillOrderMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
JSONObject save(JSONObject record); JSONObject save(JSONObject record);
@AutoSql(type = SqlType.SELECT)
List<JSONObject> findByBillId(@Param("bill_id") String bill_id);
@AutoSql(type = SqlType.UPDATE) @AutoSql(type = SqlType.UPDATE)
int update(JSONObject record); int update(JSONObject record);
List<JSONObject> findByBillIdWithWechatInfo(@Param("bill_id") String bill_id);
List<JSONObject> findByBillIdWithAlipayInfo(@Param("bill_id") String bill_id);
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
JSONObject findByClientId(@Param("client_id") int client_id); JSONObject findByClientId(@Param("client_id") int client_id);

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.bill.BillOrderMapper">
<select id="findByBillIdWithWechatInfo" resultType="com.alibaba.fastjson.JSONObject">
select o.client_id,o.order_id,o.count,o.order_total_amount,o.order_status,o.create_time,o.currency,o.customer_id
r.nickname,r.headimg
from pmt_bill_order o left join sys_customer_relation r on r.wechat_openid = o.customer_id and o.channel = 'Wechat' and o.bill_id = #{bill_id}
</select>
<select id="findByBillIdWithAlipayInfo" resultType="com.alibaba.fastjson.JSONObject">
select o.client_id,o.order_id,o.count,o.order_total_amount,o.order_status,o.create_time,o.currency,o.customer_id
r.nickname,r.headimg
from pmt_bill_order o left join sys_customer_relation_alipay r on r.alipay_uid = o.customer_id and o.channel = 'Alipay' and o.bill_id = #{bill_id}
</select>
</mapper>

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.bill.BillOrderRelationMapper">
</mapper>
Loading…
Cancel
Save