commit
308eca2a06
@ -0,0 +1,49 @@
|
||||
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;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String expire;
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getExpire() {
|
||||
return expire;
|
||||
}
|
||||
|
||||
public void setExpire(String expire) {
|
||||
this.expire = expire;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package au.com.royalpay.payment.manage.bill.bean;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* Created by wangning on 26/02/2018.
|
||||
*/
|
||||
public class QueryBillBean {
|
||||
private String status;
|
||||
private int page = 1;
|
||||
private int limit = 20;
|
||||
|
||||
public JSONObject toParams(){
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("status",status);
|
||||
return params;
|
||||
}
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package au.com.royalpay.payment.manage.bill.bean;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* Created by wangning on 26/02/2018.
|
||||
*/
|
||||
public class QueryBillOrderBean {
|
||||
private String status;
|
||||
private int page = 1;
|
||||
private int limit = 20;
|
||||
|
||||
public JSONObject toParams(){
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("status",status);
|
||||
return param;
|
||||
}
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package au.com.royalpay.payment.manage.bill.core;
|
||||
|
||||
import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wangning on 11/02/2018.
|
||||
*/
|
||||
public interface BillOrderService {
|
||||
|
||||
List<JSONObject> getByBillId(String bill_id, int client_id);
|
||||
|
||||
JSONObject query(String bill_id,int client_id, QueryBillOrderBean queryBillOrderBean);
|
||||
|
||||
JSONObject analysis(String bill_id,int client_id, QueryBillOrderBean queryBillOrderBean);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package au.com.royalpay.payment.manage.bill.core;
|
||||
|
||||
import au.com.royalpay.payment.manage.bill.bean.NewBillBean;
|
||||
import au.com.royalpay.payment.manage.bill.bean.QueryBillBean;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* Created by wangning on 11/02/2018.
|
||||
*/
|
||||
public interface BillService {
|
||||
|
||||
JSONObject getBillDetail(String billId,int client_id);
|
||||
|
||||
void updateBillStatus(String billId,String status,int client_id);
|
||||
|
||||
void removeBill(String billId);
|
||||
|
||||
JSONObject save(int client_id,NewBillBean newBillBean);
|
||||
|
||||
JSONObject queryBills(int client_id, QueryBillBean queryBillBean);
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
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.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
||||
|
||||
import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean;
|
||||
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.BillOrderMapper;
|
||||
import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper;
|
||||
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
||||
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
||||
|
||||
/**
|
||||
* Created by wangning on 11/02/2018.
|
||||
*/
|
||||
@Service
|
||||
public class BillOrderServiceImpl implements BillOrderService {
|
||||
@Resource
|
||||
private BillOrderMapper billOrderMapper;
|
||||
@Resource
|
||||
private BillMapper billMapper;
|
||||
@Resource
|
||||
private CustomerRelationAlipayMapper customerRelationAlipayMapper;
|
||||
|
||||
@Override
|
||||
public List<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");
|
||||
}
|
||||
List<JSONObject> wechatBillOrders = billOrderMapper.findByBillIdWithWechatInfo(bill_id);
|
||||
for (JSONObject order : wechatBillOrders) {
|
||||
if ("Alipay".equals(order.getString("channel"))) {
|
||||
JSONObject alipayInfo = customerRelationAlipayMapper.findCustomerByUserId(order.getString("customer_id"));
|
||||
if (alipayInfo != null) {
|
||||
order.put("nickname", alipayInfo.getString("nickname"));
|
||||
order.put("headimg", alipayInfo.getString("headimg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return wechatBillOrders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject query(String bill_id, int client_id, QueryBillOrderBean queryBillOrderBean) {
|
||||
JSONObject bill = billMapper.findOne(bill_id);
|
||||
if (bill.getIntValue("client_id") != client_id) {
|
||||
throw new BadRequestException("You have no right to check this bill");
|
||||
}
|
||||
PageList<JSONObject> list = billOrderMapper.query(bill_id, queryBillOrderBean.toParams(),
|
||||
new PageBounds(queryBillOrderBean.getPage(), queryBillOrderBean.getLimit()));
|
||||
for (JSONObject order : list) {
|
||||
order.put("currency",bill.getString("currency"));
|
||||
}
|
||||
return PageListUtils.buildPageListResult(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject analysis(String bill_id, int client_id, QueryBillOrderBean queryBillOrderBean) {
|
||||
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 billOrderMapper.analysis(bill_id, queryBillOrderBean.toParams());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package au.com.royalpay.payment.manage.bill.core.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
||||
|
||||
import au.com.royalpay.payment.manage.bill.bean.NewBillBean;
|
||||
import au.com.royalpay.payment.manage.bill.bean.QueryBillBean;
|
||||
import au.com.royalpay.payment.manage.bill.core.BillService;
|
||||
import au.com.royalpay.payment.manage.mappers.bill.BillMapper;
|
||||
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
||||
import au.com.royalpay.payment.tools.CommonConsts;
|
||||
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
||||
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
||||
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
||||
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
||||
|
||||
/**
|
||||
* Created by wangning on 11/02/2018.
|
||||
*/
|
||||
@Service
|
||||
public class BillServiceImpl implements BillService {
|
||||
@Resource
|
||||
private BillMapper billMapper;
|
||||
@Resource
|
||||
private ClientManager clientManager;
|
||||
|
||||
@Override
|
||||
public JSONObject save(int client_id, NewBillBean newBillBean) {
|
||||
JSONObject client = clientManager.getClientInfo(client_id);
|
||||
// if(client==null){
|
||||
// throw new NotFoundException("client info not found");
|
||||
// }
|
||||
Date now = new Date();
|
||||
JSONObject record = new JSONObject();
|
||||
record.put("client_id", client_id);
|
||||
record.put("price", newBillBean.getAmount().divide(CommonConsts.HUNDRED,2, BigDecimal.ROUND_DOWN));
|
||||
record.put("currency", newBillBean.getCurrency());
|
||||
record.put("remark", newBillBean.getRemark());
|
||||
record.put("create_time", now);
|
||||
record.put("cancle_time", addExpire(now, newBillBean.getExpire()));
|
||||
record.put("status", 1);
|
||||
billMapper.save(record);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("partner_name",client.getString("short_name"));
|
||||
result.put("partner_code",client.getString("client_moniker"));
|
||||
result.put("full_name",client.getString("company_name"));
|
||||
result.put("code_url", PlatformEnvironment.getEnv().concatUrl("/bills/payment/orders/"+record.getString("blll_id")));
|
||||
result.put("bill",record);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryBills(int client_id, QueryBillBean queryBillBean) {
|
||||
JSONObject params = queryBillBean.toParams();
|
||||
params.put("client_id", client_id);
|
||||
PageList<JSONObject> list = billMapper.listWithOrderAnalysis(params, new PageBounds(queryBillBean.getPage(), queryBillBean.getLimit()));
|
||||
return PageListUtils.buildPageListResult(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
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, 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");
|
||||
}
|
||||
JSONObject record = new JSONObject();
|
||||
record.put("bill_id", billId);
|
||||
record.put("status", status);
|
||||
billMapper.update(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBill(String billId) {
|
||||
billMapper.delete(billId);
|
||||
}
|
||||
|
||||
private Date addExpire(Date now, String expire) {
|
||||
if (Integer.valueOf(expire.substring(0, expire.length() - 1)) == 0) {
|
||||
return null;
|
||||
}
|
||||
String unit = expire.substring(expire.length() - 1, expire.length());
|
||||
switch (unit) {
|
||||
case "s":
|
||||
return DateUtils.addSeconds(now, Integer.valueOf(expire.substring(0, expire.length() - 1)));
|
||||
case "h":
|
||||
return DateUtils.addHours(now, Integer.valueOf(expire.substring(0, expire.length() - 1)));
|
||||
case "d":
|
||||
return DateUtils.addDays(now, Integer.valueOf(expire.substring(0, expire.length() - 1)));
|
||||
}
|
||||
throw new ServerErrorException("日期单位不正确");
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package au.com.royalpay.payment.manage.mappers.bill;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
||||
|
||||
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)
|
||||
int 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)
|
||||
List<JSONObject> findByClientId(@Param("client_id") int client_id);
|
||||
|
||||
@AutoSql(type = SqlType.DELETE)
|
||||
void delete(@Param("bill_id") String billId);
|
||||
|
||||
PageList<JSONObject> listWithOrderAnalysis(@Param("param") JSONObject jsonObject, PageBounds pageBounds);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package au.com.royalpay.payment.manage.mappers.bill;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
||||
|
||||
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 BillOrderMapper {
|
||||
@AutoSql(type = SqlType.INSERT)
|
||||
JSONObject save(JSONObject record);
|
||||
|
||||
@AutoSql(type = SqlType.UPDATE)
|
||||
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)
|
||||
JSONObject findByClientId(@Param("client_id") int client_id);
|
||||
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
List<JSONObject> findByBillId(@Param("bill_id") String bill_id);
|
||||
|
||||
PageList<JSONObject> query(@Param("bill_id") String bill_id, @Param("param") JSONObject jsonObject, PageBounds pageBounds);
|
||||
|
||||
JSONObject analysis(@Param("bill_id")String bill_id,@Param("param")JSONObject jsonObject);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?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.BillMapper">
|
||||
|
||||
<select id="listWithOrderAnalysis" resultType="com.alibaba.fastjson.JSONObject" >
|
||||
select b.bill_id,b.status,b.currency,DATE_FORMAT(b.create_time,'%Y-%c-%e') create_date, DATE_FORMAT(b.create_time,'%H:%m:%s') create_time,b.remark,b.price,count(o.bill_order_id) order_counts,sum(o.order_total_amount) order_total_amount
|
||||
from pmt_bill b left join pmt_bill_order o
|
||||
on b.bill_id = o.bill_id and o.order_status < 2
|
||||
<where>
|
||||
b.client_id = #{param.client_id}
|
||||
<if test="param.status != null">
|
||||
and o.order_status = #{param.status}
|
||||
</if>
|
||||
</where>
|
||||
group by b.bill_id,create_time,create_date,b.remark,b.price,b.status,b.currency
|
||||
order by b.create_time desc
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,33 @@
|
||||
<?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.order_total_amount,o.order_status,o.create_time,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.order_total_amount,o.order_status,o.create_time,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>
|
||||
|
||||
<select id="query" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select * from pmt_bill_order
|
||||
where
|
||||
bill_id = #{bill_id}
|
||||
<if test="param.status != null">
|
||||
and order_status = #{param.status}
|
||||
</if>
|
||||
order by create_time
|
||||
</select>
|
||||
|
||||
<select id="analysis" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select count(1) counts from pmt_bill_order
|
||||
where
|
||||
bill_id = #{bill_id}
|
||||
<if test="param.status != null">
|
||||
and order_status = #{param.status}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in new issue