@ -4,10 +4,11 @@ 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.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 ;
@ -15,6 +16,7 @@ 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.
@ -27,30 +29,53 @@ public class BillOrderServiceImpl implements BillOrderService {
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 ) {
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" ) ) ) {
if ( "Alipay" . equals ( order . getString ( "channel" ) ) ) {
JSONObject alipayInfo = customerRelationAlipayMapper . findCustomerByUserId ( order . getString ( "customer_id" ) ) ;
order . put ( "nickname" , alipayInfo . getString ( "nickname" ) ) ;
order . put ( "headimg" , alipayInfo . getString ( "headimg" ) ) ;
if ( alipayInfo ! = null ) {
order . put ( "nickname" , alipayInfo . getString ( "nickname" ) ) ;
order . put ( "headimg" , alipayInfo . getString ( "headimg" ) ) ;
}
}
}
return wechatBillOrders ;
}
@Override
public List < JSONObject > query ( String bill_id , int client_id , QueryBillOrderBean queryBillOrderBean ) {
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 . queryWithWechatInfo ( bill_id , queryBillOrderBean . toParams ( ) ,
new PageBounds ( queryBillOrderBean . getPage ( ) , queryBillOrderBean . getLimit ( ) ) ) ;
for ( JSONObject jsonObject : list ) {
if ( "Alipay" . equals ( jsonObject . getString ( "channel" ) ) ) {
JSONObject alipayInfo = customerRelationAlipayMapper . findCustomerByUserId ( jsonObject . getString ( "customer_id" ) ) ;
if ( alipayInfo ! = null ) {
jsonObject . put ( "nickname" , alipayInfo . getString ( "nickname" ) ) ;
jsonObject . put ( "headimg" , alipayInfo . getString ( "headimg" ) ) ;
}
}
}
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 ) {
if ( bill . getIntValue ( "client_id" ) ! = client_id ) {
throw new BadRequestException ( "You have no right to check this bill" ) ;
}
return billOrderMapper . query ( bill_id , queryBillOrderBean . toParams ( ) ) ;
return billOrderMapper . analysis( bill_id , queryBillOrderBean . toParams ( ) ) ;
}
}