@ -58,11 +58,9 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
" OR ait.ACARNO = '' \n" +
" OR ait.ACARNO = 'null' THEN\n" +
" '' ELSE to_char(\n" +
" CONCAT(\n" +
" substr( ait.ACARNO, 1, instr( ait.ACARNO, '_' ) - 1 ) || '_',\n" +
" substr( ait.ACARNO, 1, instr( ait.ACARNO, '_' ) - 1 ) || '_' || " +
" ( SELECT text FROM PLATECOLOR_TEXT WHERE value = substr( ait.ACARNO, instr( ait.ACARNO, '_' ) + 1 ) ) \n" +
" ) \n" +
" ) \n" +
" END AS ACARNONAME,\n" +
"\t(\n" +
"\tCASE\n" +
@ -100,12 +98,10 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
"\t CASE WHEN ait.ACARNO IS NULL \n" +
" OR ait.ACARNO = '' \n" +
" OR ait.ACARNO = 'null' THEN\n" +
" '' ELSE to_char(\n" +
" CONCAT(\n" +
" '' ELSE CONCAT(\n" +
" substr( ait.ACARNO, 1, instr( ait.ACARNO, '_' ) - 1 ) , '_',\n" +
" ( SELECT text FROM PLATECOLOR_TEXT WHERE value = substr( ait.ACARNO, instr( ait.ACARNO, '_' ) + 1 ) ) \n" +
" ) \n" +
" ) \n" +
" END AS ACARNONAME,\n" +
"\t(\n" +
"\tCASE\n" +
@ -132,7 +128,7 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
public static String returnSql = "SELECT ID,AREANAME,USERNAME,STROEPIC,APPOINTMENTTIME,CREATETIME,TOTALINTEGRAL,APPOINTMENTTYPE," +
"MEALS,MEALSCOUNT,APPOINTMENTLINEID,INTEGRATIONLISTID,ACARNONAME,ORDERID,COMPLETESTATUS,(CASE COMPLETESTATUS WHEN 1 THEN '待使用' WHEN 2 THEN '已使用' ELSE '已过期' END ) AS COMPLETESTATUSNAME " ;
@Override
public List getList ( String id , String userId, String appointmentType , String orderSope , int start , int end ) {
public List getList ( String id , String orderId, String userId, String appointmentType , String orderSope , int start , int end ) {
List list = null ;
List listRet = new ArrayList ( ) ;
String sqlTemp = sql ;
@ -140,6 +136,9 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
if ( ! PubTools . isNull ( id ) ) {
sqlTemp + = " and ait.ID = " + id + "" ;
}
if ( ! PubTools . isNull ( orderId ) ) {
sqlTemp + = " and ait.ORDERID='" + orderId + "'" ;
}
if ( ! PubTools . isNull ( userId ) ) {
sqlTemp + = " AND wut.OPENID='" + userId + "'" ;
}
@ -209,6 +208,8 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
ja . add ( jo ) ;
}
}
map . remove ( "STROEPIC" ) ;
map . put ( "STROEPIC" , PubTools . isEmpty ( map . get ( "STROEPIC" ) ) ? "" : PubTools . ClobToString ( map . get ( "MEALPIC" ) ) ) ;
map . put ( "MEALINFO" , ja ) ;
listRet . add ( map ) ;
}
@ -270,6 +271,7 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
String mealTotalMoney , String dateTime ) {
JSONObject retJo = new JSONObject ( ) ;
String ret = "-2" ; // -1 代表接口处理失败 1 处理成功 2 用户不存在 3 兑换积分大于用户可用积分 4 二维码信息过期 5 商户不存在 6 积分类型与消费方式不匹配 7 商户角色未设置 8 用户已冻结
String jobNumber = "" ; //商户工号
try {
String currentDate = PubTools . getCurrentDate ( ) ;
if ( "2" . equals ( appointmentType ) ) { //餐饮预约需要扣除积分
@ -332,22 +334,13 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
retJo . put ( "PAYINTEGRAL" , rebateIntegrateIFcZK ) ;
}
//查询用户累积获取的总积分.消费的不用管
/ * String totalAddIntegralSql = "SELECT COALESCE(MAX(ilt.TOTALADDINTEGRATION),0) AS TOTALADDINTEGRATION FROM INTEGRATION_LIST_TABLE ilt,WEIXN_USER_TABLE ut WHERE ilt.USERID = ut.ID AND ut.OPENID='" + openId + "'" ;
List selectforlistTotalAdd = this . mapperI . selectforlist ( totalAddIntegralSql ) ;
double totalAddIntegral = 0.0 ;
if ( selectforlistTotalAdd . size ( ) > 0 ) {
Map < String , Object > o = ( Map < String , Object > ) selectforlistTotalAdd . get ( 0 ) ;
totalAddIntegral = Double . parseDouble ( o . get ( "TOTALADDINTEGRATION" ) . toString ( ) ) ;
} * /
//判断选择的套餐是哪几个商户的, 分别消费了多少积分
String servicelistSql = "" ;
if ( "2" . equals ( DBType ) ) { //oralce数据库
servicelistSql = "select tt.JOBNUMBER,LISTAGG ( tt.ID, ',' ) WITHIN GROUP ( ORDER BY tt.JOBNUMBER ) AS MEALIDS,LISTAGG ( tt.MEALPRICE, ',' ) WITHIN GROUP ( ORDER BY tt.JOBNUMBER ) AS MEALPRICES from SERVICE_AREA_OPERATION_MEAL_TABLE tt where tt.ID in(" + mealId + ") group by tt.JOBNUMBER" ;
} else if ( "4" . equals ( DBType ) ) { //mysql数据库
servicelistSql = "select tt.JOBNUMBER,GROUP_CONCAT(tt.ID ORDER BY tt.JOBNUMBER Separator ',') AS MEALIDS,GROUP_CONCAT(tt.MEALPRICE ORDER BY tt.JOBNUMBER Separator ',') AS MEALPRICES from SERVICE_AREA_OPERATION_MEAL_TABLE tt where tt.ID in(" + mealId + ") group by tt.JOBNUMBER" ;
String serivceOperatorRole = "SELECT saot.ID,saot.USERNAME,saot.ROLEID,saot.JOBNUMBER,saot.SERVICEAREAID FROM SERVICE_AREA_OPERATORS_TABLE saot" +
" WHERE saot.ID=" + operatorId + "" ;
List serviceOperatorList = this . mapperI . selectforlist ( serivceOperatorRole ) ;
if ( serviceOperatorList ! = null & & serviceOperatorList . size ( ) > 0 ) { //商户不存在
Map < String , Object > oTemp = ( Map < String , Object > ) serviceOperatorList . get ( 0 ) ;
jobNumber = oTemp . get ( "JOBNUMBER" ) . toString ( ) ;
}
//List serviceforlist = this.mapperI.selectforlist(servicelistSql);
String integralListId = "" ; //积分流水的ID
String enabledIntegral = "" ; //本次消费之后,剩余的餐饮积分
// if (serviceforlist != null && serviceforlist.size() > 0) {
@ -415,7 +408,7 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
} else {
integralListId + = "," + ( maxId + 1 ) ;
}
LogUtil . WriteLog_Info ( "积分核减=====积分流水已插入" , " QCode InfoServiceImpl") ;
LogUtil . WriteLog_Info ( "积分核减=====积分流水已插入" , " Apponintment InfoServiceImpl") ;
//2、新加一条消费记录
String sqlIntegralList = "insert into CAFTER_TABLE(ID,\n" +
"ACARNO,\n" +
@ -426,7 +419,7 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
"INTEGRATIONLISTID,\n" +
"ORDERID) values (\n" +
" (select COALESCE(max(t.ID),0)+1 from CAFTER_TABLE t),''," +
"" + userIdNew + ",to_date('" + rollbackTime + "','yyyy-MM-dd HH24:mi:ss'),'" + operatorId + "','SUCCESS'," + ( maxId + 1 ) + ",'" + operatorId + "'" +
"" + userIdNew + ",to_date('" + rollbackTime + "','yyyy-MM-dd HH24:mi:ss'),'" + jobNumber + "','SUCCESS'," + ( maxId + 1 ) + ",'" + operatorId + "'" +
")" ;
if ( "4" . equals ( DBType ) ) {
sqlIntegralList = "insert into CAFTER_TABLE(ID,\n" +
@ -438,11 +431,11 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
"INTEGRATIONLISTID,\n" +
"ORDERID) values (\n" +
" (select COALESCE(max(t.ID),0)+1 from CAFTER_TABLE t),''," +
"" + userIdNew + ",str_to_date('" + rollbackTime + "','%Y-%m-%d %H:%i:%s'),'" + operatorId + "','SUCCESS'," + ( maxId + 1 ) + ",'" + operatorId + "'" +
"" + userIdNew + ",str_to_date('" + rollbackTime + "','%Y-%m-%d %H:%i:%s'),'" + jobNumber + "','SUCCESS'," + ( maxId + 1 ) + ",'" + jobNumber + "'" +
")" ;
}
this . mapperI . insert ( sqlIntegralList ) ;
LogUtil . WriteLog_Info ( "积分核减=====消费记录已插入" , " QCode InfoServiceImpl") ;
LogUtil . WriteLog_Info ( "积分核减=====消费记录已插入" , " Apponintment InfoServiceImpl") ;
// }
String currentDate1 = PubTools . getCurrentDateNoStr ( ) . replace ( "-" , "" ) . trim ( ) + PubTools . getlinkNo ( ) ;
String sqlTemp2 = "insert into APPOINTMENT_INFO_TABLE(ID,USERID,ACARNO,APPOINTMENTTYPE,APPOINTMENTTIME,APPOINTMENTLINEID,CREATETIME,SERVICEAREAID,MEALS,MEALSCOUNT,COMPLETESTATUS,INTEGRATIONLISTID,SERVICEOPERATIONID,TOTALINTEGRAL,ORDERID) " +
@ -475,12 +468,13 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
enabledIntegral = PubTools . doubleSave1 ( enabledTICp / 100 ) + "" ;
retJo . put ( "ENABLEINTEGRATION" , enabledIntegral ) ;
retJo . put ( "ORDERID" , currentDate1 ) ;
LogUtil . WriteLog_Info ( "用户更新可用积分完成" , " QCode InfoServiceImpl") ;
LogUtil . WriteLog_Info ( "用户更新可用积分完成" , " Apponintment InfoServiceImpl") ;
}
//发送消息
String integralTypePu = "餐饮预约" ;
String consumeIntegral = rebateIntegrateSave + "" ;
LogUtil . WriteLog_Info ( "餐饮预约积分核减已完成=====" + PubTools . getCurrentDate ( ) , "ApponintmentInfoServiceImpl" ) ;
String integralTypePu = "餐饮预约" ;
this . messagePushServiceImpl . pushMsg ( openId , integralTypePu , "-" + consumeIntegral , enabledIntegral ) ;
//}
} else {
@ -660,9 +654,30 @@ public class ApponintmentInfoServiceImpl implements AppointmentInfoService {
}
content = dataStr + "|" + rebateIntegrateTStr + "|" + resStr ;
// content= dateTimes+"|" +serialsT +"|"+rebateIntegrateT+"|"+res;
LogUtil . WriteLog_Info ( "用户:" + openId + "---->核销积分类型" + integrateType + "生成的流水号======" + content , "QCode InfoServiceImpl") ;
LogUtil . WriteLog_Info ( "用户:" + openId + "---->核销积分类型" + integrateType + "生成的流水号======" + content , "Apponintment InfoServiceImpl") ;
Consistant . map . put ( content , jo ) ;
return content ;
}
/ * *
* 修 改 已 经 过 期 的 数 据 状 态 为 O
* /
public void updateCompleteStastus ( ) {
String selStr = "select t.id FROM APPOINTMENT_INFO_TABLE t WHERE t.COMPLETESTATUS='N'" ;
String sql = "update APPOINTMENT_INFO_TABLE set COMPLETESTATUS='O' WHERE COMPLETESTATUS='N'" ;
if ( "2" . equals ( DBType ) ) {
selStr + = " and t.APPOINTMENTTIME <to_date('" + PubTools . getCurrentDateYYD ( ) + "','yyyy-MM-dd')" ;
sql + = " and APPOINTMENTTIME <to_date('" + PubTools . getCurrentDateYYD ( ) + "','yyyy-MM-dd')" ;
}
if ( "4" . equals ( DBType ) ) {
selStr + = " and t.APPOINTMENTTIME <str_to_date('" + PubTools . getCurrentDateYYD ( ) + "','%Y-%m-%d')" ;
sql + = " and APPOINTMENTTIME <str_to_date('" + PubTools . getCurrentDateYYD ( ) + "','%Y-%m-%d')" ;
}
List selectforlist = this . mapperI . selectforlist ( selStr ) ;
if ( selectforlist ! = null & & selectforlist . size ( ) > 0 & & ! PubTools . isEmpty ( selectforlist . get ( 0 ) ) ) {
this . mapperI . update ( sql ) ;
}
}
}