package com. xxxx. crm. query;
import com. xxxx. crm. base. BaseQuery;
public class SaleChanceQuery extends BaseQuery {
private String customerName;
private String createMan;
private String state;
}
< select id = " selectByParams" parameterType = " com.xxxx.crm.query.SaleChanceQuery"
resultType = " com.xxxx.crm.vo.SaleChance" >
select
< include refid = " Base_Column_List" />
from
t_sale_chance s
< where>
s.is_valid = 1
< if test = " customerName != null and customerName != ' ' " >
and s.customer_name like concat('%',#{customerName},'%')
</ if>
< if test = " createMan != null and createMan != ' ' " >
and s.create_man = #{createMan}
</ if>
< if test = " state != null and state != ' ' " >
and s.state = #{state}
</ if>
</ where>
</ select>
public interface SaleChanceMapper extends BaseMapper < SaleChance, Integer> {
}
@Service
public class SaleChanceService extends BaseService < SaleChance, Integer> {
@Resource
private SaleChangeMapper saleChangeMapper;
public Map< String, Object> querySaleChanceByParams ( SaleChanceQuery query) {
Map< String, Object> map = new HashMap < > ( ) ;
PageHelper. startPage ( query. getPage ( ) , query. getLimit ( ) ) ;
PageInfo< SaleChance> pageInfo =
new PageInfo < > ( saleChangeMapper. selectByParams ( query) ) ;
map. put ( "code" , 0 ) ;
map. put ( "msg" , "success" ) ;
map. put ( "count" , pageInfo. getTotal ( ) ) ;
map. put ( "data" , pageInfo. getList ( ) ) ;
return map;
}
}
@Controller
@RequestMapping ( "sale_chance" )
public class SaleChanceController extends BaseController {
@Resource
private SaleChanceService saleChanceService;
@RequestMapping ( "list" )
@ResponseBody
public Map< String, Object> querySaleChanceByParams ( SaleChanceQuery query) {
return saleChanceService. querySaleChanceByParams ( query) ;
}
}
@Transactional ( propagation = Propagation. REQUIRED)
public void updateSaleChance ( SaleChance saleChance) {
SaleChance temp = saleChanceMapper. selectByPrimaryKey ( saleChance. getId ( ) ) ;
AssertUtil. isTrue ( null == temp, "待更新记录不存在!" ) ;
checkParams ( saleChance. getCustomerName ( ) , saleChance. getLinkMan ( ) ,
saleChance. getLinkPhone ( ) ) ;
saleChance. setUpdateDate ( new Date ( ) ) ;
if ( StringUtils. isBlank ( temp. getAssignMan ( ) )
&& StringUtils. isNotBlank ( saleChance. getAssignMan ( ) ) ) {
saleChance. setState ( StateStatus. STATED. getType ( ) ) ;
saleChance. setAssignTime ( new Date ( ) ) ;
saleChance. setDevResult ( DevResult. DEVING. getStatus ( ) ) ;
} else if ( StringUtils. isNotBlank ( temp. getAssignMan ( ) )
&& StringUtils. isBlank ( saleChance. getAssignMan ( ) ) ) {
saleChance. setAssignMan ( "" ) ;
saleChance. setState ( StateStatus. UNSTATE. getType ( ) ) ;
saleChance. setAssignTime ( null) ;
saleChance. setDevResult ( DevResult. UNDEV. getStatus ( ) ) ;
}
AssertUtil. isTrue ( saleChanceMapper. updateByPrimaryKeySelective ( saleChance) <
1 , "营销机会数据更新失败!" ) ;
}