master
wangning 8 years ago
parent b89f0072c4
commit b476f2f898

@ -5,6 +5,7 @@ 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.bean.NewBillBean; 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.BillOrderService; import au.com.royalpay.payment.manage.bill.core.BillOrderService;
import au.com.royalpay.payment.manage.bill.core.BillService; 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;
@ -286,28 +287,24 @@ 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}",method = RequestMethod.GET) @RequestMapping(value = "/bills/{bill_id}",method = RequestMethod.GET)
public JSONObject getBills(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ public JSONObject getBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
device = new JSONObject();
device.put("client_id",9);
return billService.getBillDetail(bill_id,device.getIntValue("client_id")); return billService.getBillDetail(bill_id,device.getIntValue("client_id"));
} }
@RequestMapping(value = "/bill",method = RequestMethod.PUT) @RequestMapping(value = "/bills/list",method = RequestMethod.GET)
public JSONObject getBills(QueryBillBean queryBillBean,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
return billService.queryBills(device.getIntValue("client_id"),queryBillBean);
}
@RequestMapping(value = "/bills",method = RequestMethod.PUT)
public void addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@RequestBody NewBillBean newBillBean){ public void addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@RequestBody NewBillBean newBillBean){
device = new JSONObject();
device.put("client_id",9);
billService.save(device.getIntValue("client_id"),newBillBean); billService.save(device.getIntValue("client_id"),newBillBean);
} }
@RequestMapping(value = "/bill/{bill_id}/close",method = RequestMethod.POST) @RequestMapping(value = "/bills/{bill_id}/close",method = RequestMethod.POST)
public void closeBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ public void closeBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
device = new JSONObject();
device.put("client_id",9);
billService.updateBillStatus(bill_id,"2"); billService.updateBillStatus(bill_id,"2");
} }
@RequestMapping(value = "/bill/orders/{bill_id}",method = RequestMethod.GET) @RequestMapping(value = "/bills/orders/{bill_id}",method = RequestMethod.GET)
public List<JSONObject> getBillOrders(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ public List<JSONObject> getBillOrders(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
device = new JSONObject();
device.put("client_id",9);
return billOrderService.getByBillId(bill_id,device.getIntValue("client_id")); return billOrderService.getByBillId(bill_id,device.getIntValue("client_id"));
} }
} }

@ -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,10 @@
package au.com.royalpay.payment.manage.bill.bean;
/**
* Created by wangning on 26/02/2018.
*/
public class QueryBillOrderBean {
private String status;
private int page = 1;
private int limit = 20;
}

@ -10,4 +10,6 @@ import java.util.List;
public interface BillOrderService { public interface BillOrderService {
List<JSONObject> getByBillId(String bill_id, int client_id); List<JSONObject> getByBillId(String bill_id, int client_id);
List<JSONObject> query(String bill_id, int page, int limit);
} }

@ -1,11 +1,10 @@
package au.com.royalpay.payment.manage.bill.core; 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.NewBillBean;
import au.com.royalpay.payment.manage.bill.bean.QueryBillBean;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.List;
/** /**
* Created by wangning on 11/02/2018. * Created by wangning on 11/02/2018.
*/ */
@ -19,6 +18,6 @@ public interface BillService {
void save(int client_id,NewBillBean newBillBean); void save(int client_id,NewBillBean newBillBean);
List<JSONObject> getBills(int client_id); JSONObject queryBills(int client_id, QueryBillBean queryBillBean);
} }

@ -8,11 +8,16 @@ import javax.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
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.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.bill.core.BillService;
import au.com.royalpay.payment.manage.mappers.bill.BillMapper; import au.com.royalpay.payment.manage.mappers.bill.BillMapper;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.utils.PageListUtils;
/** /**
* Created by wangning on 11/02/2018. * Created by wangning on 11/02/2018.
@ -34,8 +39,9 @@ public class BillServiceImpl implements BillService {
} }
@Override @Override
public List<JSONObject> getBills(int client_id) { public JSONObject queryBills(int client_id, QueryBillBean queryBillBean) {
return billMapper.findByClientId(client_id); PageList<JSONObject> list = billMapper.listWithOrderAnalysis(queryBillBean.toParams(), new PageBounds(queryBillBean.getPage(), queryBillBean.getLimit(), Order.formString("event_time.desc")));
return PageListUtils.buildPageListResult(list);
} }
@Override @Override

@ -5,6 +5,8 @@ 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;
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.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
@ -29,4 +31,6 @@ public interface BillMapper {
@AutoSql(type = SqlType.DELETE) @AutoSql(type = SqlType.DELETE)
void delete(@Param("bill_id") String billId); void delete(@Param("bill_id") String billId);
PageList<JSONObject> listWithOrderAnalysis(@Param("param") JSONObject jsonObject, PageBounds pageBounds);
} }

@ -28,4 +28,7 @@ public interface BillOrderMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
JSONObject findByClientId(@Param("client_id") int client_id); JSONObject findByClientId(@Param("client_id") int client_id);
@AutoSql(type = SqlType.SELECT)
JSONObject findByBillId(@Param("bill_id") String bill_id);
} }

@ -2,4 +2,14 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!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"> <mapper namespace="au.com.royalpay.payment.manage.mappers.bill.BillMapper">
<select id="listWithOrderAnalysis" resultType="com.alibaba.fastjson.JSONObject" >
select b.bill_id,b.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 = 1
<where>
<if test="param.status != null">
and o.status = #{param.status}
</if>
</where>
group by b.bill_id,b.create_time,b.remark,b.price
order by b.create_time
</select>
</mapper> </mapper>
Loading…
Cancel
Save