| @@ -42,6 +42,8 @@ public class CouponInjectController extends BaseController { | |||
| if (couponInject.getStatus() != null && couponInject.getStatus() == -1) { | |||
| couponInject.setStatus(null); | |||
| } | |||
| couponInject.setTenantId(getTenantId()); | |||
| couponInject.setSortColumns(CouponInject.Field.CouponId_DESC); | |||
| final PageInfo<CouponInject> page = couponInjectService.listAsPage(couponInject, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -35,7 +35,7 @@ public class PushLimitController extends BaseController { | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody PushLimit pushLimit) { | |||
| pushLimit.setMsgAmount(null); | |||
| pushLimit.setTenantId(getTenantId()); | |||
| pushLimitService.saveOrUpdate(pushLimit); | |||
| return new ResultData(); | |||
| } | |||
| @@ -56,4 +56,13 @@ public class PushLimitController extends BaseController { | |||
| } | |||
| @ApiOperation("默认数据接口") | |||
| @GetMapping("/getDefaultData") | |||
| public ResultData getDefaultData() { | |||
| PushLimit pushLimit=pushLimitService.getDefaultData(getTenantId()); | |||
| return new ResultData(pushLimit); | |||
| } | |||
| } | |||
| @@ -31,6 +31,7 @@ public class WxMsgCallbackController extends BaseController { | |||
| public ResultData list(@ModelAttribute WxMsgCallback wxMsgCallback, Integer pageNum, Integer pageSize) { | |||
| if (null == wxMsgCallback) wxMsgCallback = new WxMsgCallback(); | |||
| wxMsgCallback.setTenantId(getTenantId()); | |||
| wxMsgCallback.setSortColumns(WxMsgCallback.Field.Createtime_DESC); | |||
| final PageInfo<WxMsgCallback> page = wxMsgCallbackService.listAsPage(wxMsgCallback, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -36,6 +36,7 @@ public class WxMsgController extends BaseController { | |||
| public ResultData list(@ModelAttribute WxMsg wxMsg, Integer pageNum, Integer pageSize) { | |||
| if (null == wxMsg) wxMsg = new WxMsg(); | |||
| wxMsg.setTenantId(getTenantId()); | |||
| wxMsg.setSortColumns(WxMsg.Field.Createtime_DESC); | |||
| final PageInfo<WxMsg> page = wxMsgService.listAsPage(wxMsg, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -29,6 +29,7 @@ public class WxMsgModelController extends BaseController { | |||
| public ResultData list(@ModelAttribute WxMsgModel wxMsgModel, Integer pageNum, Integer pageSize) { | |||
| if (null == wxMsgModel) wxMsgModel = new WxMsgModel(); | |||
| wxMsgModel.setTenantId(getTenantId()); | |||
| wxMsgModel.setSortColumns(WxMsgModel.Field.Createtime_DESC); | |||
| final PageInfo<WxMsgModel> page = wxMsgModelService.listAsPage(wxMsgModel, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -28,6 +28,7 @@ public class WxMsgSignatureController extends BaseController { | |||
| public ResultData list(@ModelAttribute WxMsgSignature wxMsgSignature, Integer pageNum, Integer pageSize) { | |||
| if (null == wxMsgSignature) wxMsgSignature = new WxMsgSignature(); | |||
| wxMsgSignature.setTenantId(getTenantId()); | |||
| wxMsgSignature.setSortColumns(WxMsgSignature.Field.Createtime_DESC); | |||
| final PageInfo<WxMsgSignature> page = wxMsgSignatureService.listAsPage(wxMsgSignature, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -57,6 +57,24 @@ public class WxMallController extends BaseController { | |||
| return new ResultData(Result.SUCCESS, "查询成功", resultMap); | |||
| } | |||
| @AuthIgnore | |||
| @ApiOperation("根据appId获取") | |||
| @GetMapping("/getWeapNote") | |||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true) | |||
| public ResultData getWeapNote(String appId) { | |||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); | |||
| if (appInfo == null) { | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| WxMall mall = wxMallService.getByTenantId(appInfo.getTenantId()); | |||
| if (mall == null) { | |||
| return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | |||
| } | |||
| Map resultMap = new HashMap(); | |||
| resultMap.put("weapNote", mall.getWeapNote()); | |||
| return new ResultData(Result.SUCCESS, "查询成功", resultMap); | |||
| } | |||
| @ApiOperation("根据appId获取") | |||
| @GetMapping("/mallInfo") | |||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true) | |||
| @@ -109,9 +109,9 @@ public class WxUserGrantController extends BaseController { | |||
| token = user1.getToken(); | |||
| user1.setRegisterIp(ipaddress); | |||
| user1.setSessionKey(session_key); | |||
| if (user1.getSceneAddress() == null) | |||
| if (user1.getSceneAddress() == null || user1.getSceneAddress().equals("undefined")) | |||
| user1.setSceneAddress(sceneAddress); | |||
| if (user1.getScene() == null) | |||
| if (user1.getScene() == null || user1.getScene().equals("undefined")) | |||
| user1.setScene(scene); | |||
| if (!StringUtils.isBlank(longitude)) | |||
| user.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); | |||
| @@ -124,9 +124,9 @@ public class WxUserGrantController extends BaseController { | |||
| user.createToken(new Date()); | |||
| token = user.getToken(); | |||
| user.setRegisterIp(ipaddress); | |||
| if (user.getSceneAddress() == null) | |||
| if (user.getSceneAddress() == null || user1.getSceneAddress().equals("undefined")) | |||
| user.setSceneAddress(sceneAddress); | |||
| if (user.getScene() == null) | |||
| if (user.getScene() == null || user1.getScene().equals("undefined")) | |||
| user.setScene(scene); | |||
| user.setSessionKey(session_key); | |||
| if (!StringUtils.isBlank(longitude)) | |||
| @@ -205,6 +205,8 @@ public enum ErrorCode{ | |||
| MSG_REQUEST_PARAMS_ERROR(12106,"参数错误"), | |||
| MSG_SEND_ERROR(12107,"发送短信失败"), | |||
| MSG_METHOD_REQUEST_ERROR(12108,"接口请求错误"), | |||
| MSG_PHONE_NOT_FOUND(12109,"请输入手机号"), | |||
| /** | |||
| * 会员 | |||
| @@ -93,6 +93,9 @@ public class WxMall implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪url",name="wiwideUrl") | |||
| private String wiwideUrl; | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序提示",name="weapNote") | |||
| private String weapNote; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| @@ -213,24 +216,34 @@ public class WxMall implements Serializable { | |||
| this.wiwideUrl = wiwideUrl; | |||
| } | |||
| public static enum Field | |||
| public String getWeapNote() { | |||
| return weapNote; | |||
| } | |||
| public void setWeapNote(String weapNote) { | |||
| this.weapNote = weapNote; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||
| ,Group_ASC("`group` ASC"),Group_DESC("`group` DESC") | |||
| ,Country_ASC("`country` ASC"),Country_DESC("`country` DESC") | |||
| ,Province_ASC("`province` ASC"),Province_DESC("`province` DESC") | |||
| ,City_ASC("`city` ASC"),City_DESC("`city` DESC") | |||
| ,Addr_ASC("`addr` ASC"),Addr_DESC("`addr` DESC") | |||
| ,WiwideId_ASC("`wiwideId` ASC"),WiwideId_DESC("`wiwideId` DESC") | |||
| ,TotalArea_ASC("`totalArea` ASC"),TotalArea_DESC("`totalArea` DESC") | |||
| ,OperatingArea_ASC("`operatingArea` ASC"),OperatingArea_DESC("`operatingArea` DESC") | |||
| ,WiwideId_ASC("`wiwide_id` ASC"),WiwideId_DESC("`wiwide_id` DESC") | |||
| ,TotalArea_ASC("`total_area` ASC"),TotalArea_DESC("`total_area` DESC") | |||
| ,OperatingArea_ASC("`operating_area` ASC"),OperatingArea_DESC("`operating_area` DESC") | |||
| ,ParkArea_ASC("`parkArea` ASC"),ParkArea_DESC("`parkArea` DESC") | |||
| ,ParkPlaceNumber_ASC("`parkPlaceNumber` ASC"),ParkPlaceNumber_DESC("`parkPlaceNumber` DESC") | |||
| ,PayId_ASC("`payId` ASC"),PayId_DESC("`payId` DESC") | |||
| ,ServicePhone_ASC("`servicePhone` ASC"),ServicePhone_DESC("`servicePhone` DESC") | |||
| ,ImgUrl_ASC("`imgUrl` ASC"),ImgUrl_DESC("`imgUrl` DESC") | |||
| ,ParkPlaceNumber_ASC("`park_place_number` ASC"),ParkPlaceNumber_DESC("`park_place_number` DESC") | |||
| ,PayId_ASC("`pay_id` ASC"),PayId_DESC("`pay_id` DESC") | |||
| ,ServicePhone_ASC("`service_phone` ASC"),ServicePhone_DESC("`service_phone` DESC") | |||
| ,ImgUrl_ASC("`img_url` ASC"),ImgUrl_DESC("`img_url` DESC") | |||
| ,ImgUrlH_ASC("`img_url_h` ASC"),ImgUrlH_DESC("`img_url_h` DESC") | |||
| ,WeapNote_ASC("`weap_note` ASC"),WeapNote_DESC("`weap_note` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| @@ -263,7 +276,8 @@ public class WxMall implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| @@ -204,15 +204,15 @@ public class WxMsg implements Serializable { | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,ModelId_ASC("`modelId` ASC"),ModelId_DESC("`modelId` DESC") | |||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||
| ,ModelId_ASC("`model_id` ASC"),ModelId_DESC("`model_id` DESC") | |||
| ,Msg_ASC("`msg` ASC"),Msg_DESC("`msg` DESC") | |||
| ,Sendtime_ASC("`sendtime` ASC"),Sendtime_DESC("`sendtime` DESC") | |||
| ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | |||
| ,ExpectSendNumber_ASC("`expectSendNumber` ASC"),ExpectSendNumber_DESC("`expectSendNumber` DESC") | |||
| ,SuccessNumber_ASC("`successNumber` ASC"),SuccessNumber_DESC("`successNumber` DESC") | |||
| ,ErrorNumber_ASC("`errorNumber` ASC"),ErrorNumber_DESC("`errorNumber` DESC") | |||
| ,ReturnResult_ASC("`returnResult` ASC"),ReturnResult_DESC("`returnResult` DESC") | |||
| ,ExpectSendNumber_ASC("`expect_send_number` ASC"),ExpectSendNumber_DESC("`expect_send_number` DESC") | |||
| ,SuccessNumber_ASC("`success_number` ASC"),SuccessNumber_DESC("`success_number` DESC") | |||
| ,ErrorNumber_ASC("`error_number` ASC"),ErrorNumber_DESC("`error_number` DESC") | |||
| ,ReturnResult_ASC("`return_result` ASC"),ReturnResult_DESC("`return_result` DESC") | |||
| ,Phones_ASC("`phones` ASC"),Phones_DESC("`phones` DESC") | |||
| ,Signature_ASC("`signature` ASC"),Signature_DESC("`signature` DESC") | |||
| ,Isright_ASC("`isright` ASC"),Isright_DESC("`isright` DESC") | |||
| @@ -250,6 +250,8 @@ public class WxMsg implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| @@ -127,13 +127,13 @@ public class WxMsgCallback implements Serializable { | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,BatchNo_ASC("`batchNo` ASC"),BatchNo_DESC("`batchNo` DESC") | |||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||
| ,BatchNo_ASC("`batch_no` ASC"),BatchNo_DESC("`batch_no` DESC") | |||
| ,Phone_ASC("`phone` ASC"),Phone_DESC("`phone` DESC") | |||
| ,Begintime_ASC("`begintime` ASC"),Begintime_DESC("`begintime` DESC") | |||
| ,Endtime_ASC("`endtime` ASC"),Endtime_DESC("`endtime` DESC") | |||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | |||
| ,StatusMsg_ASC("`statusMsg` ASC"),StatusMsg_DESC("`statusMsg` DESC") | |||
| ,StatusMsg_ASC("`status_msg` ASC"),StatusMsg_DESC("`status_msg` DESC") | |||
| ,Sign_ASC("`sign` ASC"),Sign_DESC("`sign` DESC") | |||
| ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | |||
| ; | |||
| @@ -168,6 +168,8 @@ public class WxMsgCallback implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| @@ -111,13 +111,13 @@ public class WxMsgModel implements Serializable { | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||
| ,Signature_ASC("`signature` ASC"),Signature_DESC("`signature` DESC") | |||
| ,Content_ASC("`content` ASC"),Content_DESC("`content` DESC") | |||
| ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | |||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | |||
| ,ModelId_ASC("`modelId` ASC"),ModelId_DESC("`modelId` DESC") | |||
| ,ModelId_ASC("`model_id` ASC"),ModelId_DESC("`model_id` DESC") | |||
| ; | |||
| private String value; | |||
| @@ -151,6 +151,8 @@ public class WxMsgModel implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| @@ -73,7 +73,7 @@ public class WxMsgSignature implements Serializable { | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||
| ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | |||
| ; | |||
| @@ -108,6 +108,8 @@ public class WxMsgSignature implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| @@ -0,0 +1,41 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumMsgStatus { | |||
| MSG_STATUS_DRAFT(2, "草稿"), | |||
| MSG_STATUS_NOT_SEND(0, "未发送"), | |||
| MSG_STATUS_SENDED(1, "已发送"), | |||
| MSG_SEND_STATUS_SET_TIME(0, "定时"), | |||
| MSG_SEND_IMMEDIATELY(1, "立即发送"), | |||
| MSG_SEND_NOT_IMMEDIATELY(0, "不立即发送"), | |||
| MSG_SEND_SUCCESS(1,"发送成功"), | |||
| MSG_SEND_FAIL(0,"发送失败") | |||
| ; | |||
| public static EnumMsgStatus getEnum(Integer code) { | |||
| for (EnumMsgStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumMsgStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -26,8 +26,8 @@ public interface PushLimitService { | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(PushLimit record); | |||
| /** | |||
| @@ -36,12 +36,7 @@ public interface PushLimitService { | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| PushLimit getDefaultData(String tenantId); | |||
| } | |||
| @@ -9,6 +9,8 @@ import com.iformall.service.PushLimitService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.List; | |||
| @Service | |||
| public class PushLimitServiceImpl implements PushLimitService { | |||
| @@ -28,26 +30,50 @@ public class PushLimitServiceImpl implements PushLimitService { | |||
| @Override | |||
| public void saveOrUpdate(PushLimit record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| PushLimit params=new PushLimit(); | |||
| params.setTenantId(record.getTenantId()); | |||
| List<PushLimit> list = pushLimitMapper.findList(params); | |||
| if(list.size()>0){ | |||
| pushLimitMapper.updateByPrimaryKeySelective(record); | |||
| }else{ | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| pushLimitMapper.insertSelective(record); | |||
| } else { | |||
| pushLimitMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| // if (record.getId() == null) { | |||
| // //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| // final IdWorker idWorker = IdWorker.get(); | |||
| // record.setId(idWorker.nextId()); | |||
| // pushLimitMapper.insertSelective(record); | |||
| // return record.getId(); | |||
| // } else { | |||
| // pushLimitMapper.updateByPrimaryKeySelective(record); | |||
| // return record.getId(); | |||
| // } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| pushLimitMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public PushLimit getDefaultData(String tenantId) { | |||
| PushLimit record =new PushLimit(); | |||
| record.setTenantId(tenantId); | |||
| List<PushLimit> list = pushLimitMapper.findList(record); | |||
| if(list.size()>0){ | |||
| record=list.get(0); | |||
| }else{ | |||
| record=new PushLimit(); | |||
| record.setMsgAmount(3); | |||
| record.setRefuseTimeStart("00:00"); | |||
| record.setRefuseTimeEnd("23:45"); | |||
| record.setCouponDay(10); | |||
| record.setCouponAmount(10); | |||
| } | |||
| return record; | |||
| } | |||
| } | |||
| @@ -12,6 +12,7 @@ import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxMsg; | |||
| import com.iformall.domain.po.WxMsgConfig; | |||
| import com.iformall.enums.EnumMsgStatus; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.WxCUserTagsService; | |||
| @@ -23,6 +24,7 @@ import com.iformall.utils.RsaUtil; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.beans.Encoder; | |||
| import java.util.*; | |||
| @Service | |||
| @@ -66,7 +68,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| } | |||
| if(phones.equals("")){ | |||
| return new ResultData(Result.SUCCESS, "您需要添加要发送的手机号"); | |||
| return new ResultData(ErrorCode.MSG_PHONE_NOT_FOUND, "请输入手机号"); | |||
| } | |||
| if (wxMsg.getId() == null) { | |||
| @@ -82,10 +84,10 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| //是否立即发送 | |||
| if (wxMsg.getIsright() == 1) { | |||
| wxMsg.setStatus(1); | |||
| wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | |||
| sendmsg(wxMsg); | |||
| } else { | |||
| wxMsg.setStatus(0); | |||
| wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_NOT_SEND.getCode()); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsg.setId(idWorker.nextId()); | |||
| wxMsg.setCreatetime(new Date()); | |||
| @@ -102,11 +104,11 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| //是否立即发送 | |||
| if (wxMsg.getIsright() == 1) { | |||
| wxMsg.setStatus(1); | |||
| wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | |||
| sendmsg(wxMsg); | |||
| } else { | |||
| //定时 | |||
| wxMsg.setStatus(0); | |||
| wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_NOT_SEND.getCode()); | |||
| wxMsgMapper.updateByPrimaryKeySelective(wxMsg); | |||
| return new ResultData(Result.SUCCESS, "短信会在预设时间发送"); | |||
| @@ -152,7 +154,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||
| wxMsgConfig.setTenantId(wxMsg.getTenantId()); | |||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||
| if (wxMsgConfigs.size() == 0) return new ResultData(Result.SUCCESS, "您还未接入短信运营商,请联系平台管理员"); | |||
| if (wxMsgConfigs.size() == 0) return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND, "您还未接入短信运营商,请联系平台管理员"); | |||
| wxMsgConfig = wxMsgConfigs.get(0); | |||
| String secret = wxMsgConfig.getSecret(); | |||
| @@ -201,9 +203,9 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| String ret = jsonObjectResult.get("ret").toString(); | |||
| if (ret.equals("1")) { | |||
| wxMsg.setSendstatus(1); | |||
| wxMsg.setSendstatus(EnumMsgStatus.MSG_SEND_SUCCESS.getCode()); | |||
| } else { | |||
| wxMsg.setSendstatus(0); | |||
| wxMsg.setSendstatus(EnumMsgStatus.MSG_SEND_FAIL.getCode()); | |||
| } | |||
| if (wxMsg.getId() == null) { | |||
| @@ -20,6 +20,7 @@ import com.iformall.pay.WxRefundOrderSP; | |||
| import com.iformall.service.WxOrderService; | |||
| import com.iformall.service.WxRefundOrderService; | |||
| import com.iformall.utils.BeanUtils; | |||
| import com.iformall.utils.CipherUtil; | |||
| import com.iformall.utils.Utility; | |||
| import com.iformall.utils.XmlUtil; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -457,7 +458,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| record.setRefundId(refund_id); | |||
| record.setRefundVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); | |||
| if ("SUCCESS".equals(result_no)) { | |||
| logger.error("微信退款订单申请成功: " + returnMap.toString()); | |||
| logger.info("微信退款订单申请成功: " + returnMap.toString()); | |||
| try { | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_SUCCESS.getCode()); | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| @@ -536,7 +537,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| record.setRefundId(refund_id); | |||
| record.setRefundVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); | |||
| if ("SUCCESS".equals(result_no)) { | |||
| logger.error("微信退款订单申请成功: " + returnMap.toString()); | |||
| logger.info("微信退款订单申请成功: " + returnMap.toString()); | |||
| try { | |||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_SUCCESS.getCode()); | |||
| wxRefundOrderMapper.updateByPrimaryKey(record); | |||
| @@ -689,60 +690,57 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| String partnerKey = payAccount.getApiKey(); | |||
| try { | |||
| if (payWay == EnumPayWay.PAY_WAY_WEAPP) { | |||
| boolean signVerified = false; | |||
| // 微信支付 | |||
| signVerified = WxPayment.verifyNotify(paramMap, partnerKey); | |||
| if (!signVerified) { | |||
| logger.warn("notify order, wxpay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); | |||
| } | |||
| if (!"SUCCESS".equals(paramMap.get("return_code"))) { | |||
| logger.warn("notify order, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| logger.warn("notify refund, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单状态码非SUCCESS"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String payOrderNo = paramMap.get("out_trade_no"); | |||
| // 解密req_info | |||
| String req_info = CipherUtil.decryptReqInfo(paramMap.get("req_info"), partnerKey); | |||
| Map<String, String> reqMap = WxPayment.xmlToMap(req_info); | |||
| String payOrderNo = reqMap.get("out_trade_no"); | |||
| Long payOrderId = Long.valueOf(payOrderNo); | |||
| WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId); | |||
| if (payOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| logger.warn("notify refund, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "支付订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| if(!reqMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||
| logger.warn("notify refund, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "支付订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String refundIdStr = paramMap.get("out_refund_no"); | |||
| String refundIdStr = reqMap.get("out_refund_no"); | |||
| Long refundOrderId = Long.valueOf(refundIdStr); | |||
| WxRefundOrder refundOrder = wxRefundOrderMapper.selectByPrimaryKey(refundOrderId); | |||
| if (refundOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| logger.warn("notify refund, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| if(!reqMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) { | |||
| logger.warn("notify refund, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证退款金额 | |||
| if(!paramMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) { | |||
| logger.warn("notify order, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| if(!reqMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) { | |||
| logger.warn("notify refund, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款总金额不一致"); | |||
| @@ -750,16 +748,19 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| } | |||
| // 处理支付成功 | |||
| handleRefundSuccess(refundOrder, paramMap.get("transaction_id"), paramMap.get("refund_id")); | |||
| logger.info("notify order, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| handleRefundSuccess(refundOrder, reqMap.get("transaction_id"), reqMap.get("refund_id")); | |||
| logger.info("notify refund, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| resultMap.put("return_msg", "OK"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| } catch (RuntimeException e) { | |||
| logger.warn("notify order, alipay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| logger.warn("notify refund paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.warn("notify refund, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } else { | |||
| // 服务号回调 | |||
| @@ -780,13 +781,6 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| String partnerKey = payAccount.getApiKey(); | |||
| try { | |||
| if (payWay == EnumPayWay.PAY_WAY_WEAPP) { | |||
| boolean signVerified = false; | |||
| // 微信支付 | |||
| signVerified = WxPayment.verifyNotifyHMAC(paramMap, partnerKey); | |||
| if (!signVerified) { | |||
| logger.warn("notify order, wxpay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); | |||
| } | |||
| if (!"SUCCESS".equals(paramMap.get("return_code"))) { | |||
| logger.warn("notify order, wxpay status not success, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| @@ -795,7 +789,12 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String payOrderNo = paramMap.get("out_trade_no"); | |||
| // 解密req_info | |||
| String req_info = CipherUtil.decryptReqInfo(paramMap.get("req_info"), partnerKey); | |||
| logger.info(req_info); | |||
| Map<String, String> reqMap = WxPayment.xmlToMap(req_info); | |||
| String payOrderNo = reqMap.get("out_trade_no"); | |||
| if (payOrderNo == null) { | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| @@ -805,41 +804,41 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| Long payOrderId = Long.valueOf(payOrderNo); | |||
| WxPayOrder payOrder = wxPayOrderMapper.selectByPrimaryKey(payOrderId); | |||
| if (payOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| logger.warn("notify refund, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "支付订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| if(!reqMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||
| logger.warn("notify refund, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "支付订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String refundIdStr = paramMap.get("out_refund_no"); | |||
| String refundIdStr = reqMap.get("out_refund_no"); | |||
| Long refundOrderId = Long.valueOf(refundIdStr); | |||
| WxRefundOrder refundOrder = wxRefundOrderMapper.selectByPrimaryKey(refundOrderId); | |||
| if (refundOrder == null) { | |||
| logger.warn("notify order, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| logger.warn("notify refund, wxpay check pay order not exists, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if(!paramMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) { | |||
| logger.warn("notify order, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| if(!reqMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) { | |||
| logger.warn("notify refund, wxpay check total_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证退款金额 | |||
| if(!paramMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) { | |||
| logger.warn("notify order, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| if(!reqMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) { | |||
| logger.warn("notify refund, wxpay check refund_fee is invalid, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "退款总金额不一致"); | |||
| @@ -847,16 +846,19 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| } | |||
| // 处理支付成功 | |||
| handleRefundSuccess(refundOrder, paramMap.get("transaction_id"), paramMap.get("refund_id")); | |||
| logger.info("notify order, wxpay checksign success, paramMap:{}, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString()); | |||
| handleRefundSuccess(refundOrder, reqMap.get("transaction_id"), reqMap.get("refund_id")); | |||
| logger.info("notify refund, wxpay checksign success, paramMap:{}, paramMap: "+reqMap.toString()+ ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| resultMap.put("return_msg", "OK"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| } catch (RuntimeException e) { | |||
| logger.warn("notify order, wepay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| logger.warn("notify refund, wepay checksign error, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); | |||
| } catch (Exception e) { | |||
| logger.warn("notify refund, paramMap: "+paramMap.toString()+ ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,312 @@ | |||
| package com.iformall.utils; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| import java.io.Writer; | |||
| public class Base64Util { | |||
| private static final char S_BASE64CHAR[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', | |||
| 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', | |||
| 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; | |||
| private static final byte S_DECODETABLE[]; | |||
| static { | |||
| S_DECODETABLE = new byte[128]; | |||
| for (int i = 0; i < S_DECODETABLE.length; i++) | |||
| S_DECODETABLE[i] = 127; | |||
| for (int i = 0; i < S_BASE64CHAR.length; i++) | |||
| S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i; | |||
| } | |||
| /** | |||
| * | |||
| * @param ibuf | |||
| * @param obuf | |||
| * @param wp | |||
| * @return | |||
| */ | |||
| private static int decode0(char ibuf[], byte obuf[], int wp) { | |||
| int outlen = 3; | |||
| if (ibuf[3] == '=') | |||
| outlen = 2; | |||
| if (ibuf[2] == '=') | |||
| outlen = 1; | |||
| int b0 = S_DECODETABLE[ibuf[0]]; | |||
| int b1 = S_DECODETABLE[ibuf[1]]; | |||
| int b2 = S_DECODETABLE[ibuf[2]]; | |||
| int b3 = S_DECODETABLE[ibuf[3]]; | |||
| switch (outlen) { | |||
| case 1: // '\001' | |||
| obuf[wp] = (byte) (b0 << 2 & 252 | b1 >> 4 & 3); | |||
| return 1; | |||
| case 2: // '\002' | |||
| obuf[wp++] = (byte) (b0 << 2 & 252 | b1 >> 4 & 3); | |||
| obuf[wp] = (byte) (b1 << 4 & 240 | b2 >> 2 & 15); | |||
| return 2; | |||
| case 3: // '\003' | |||
| obuf[wp++] = (byte) (b0 << 2 & 252 | b1 >> 4 & 3); | |||
| obuf[wp++] = (byte) (b1 << 4 & 240 | b2 >> 2 & 15); | |||
| obuf[wp] = (byte) (b2 << 6 & 192 | b3 & 63); | |||
| return 3; | |||
| } | |||
| throw new RuntimeException("Internal error"); | |||
| } | |||
| /** | |||
| * | |||
| * @param data | |||
| * @param off | |||
| * @param len | |||
| * @return | |||
| */ | |||
| public static byte[] decode(char data[], int off, int len) { | |||
| char ibuf[] = new char[4]; | |||
| int ibufcount = 0; | |||
| byte obuf[] = new byte[(len / 4) * 3 + 3]; | |||
| int obufcount = 0; | |||
| for (int i = off; i < off + len; i++) { | |||
| char ch = data[i]; | |||
| if (ch != '=' && (ch >= S_DECODETABLE.length || S_DECODETABLE[ch] == 127)) | |||
| continue; | |||
| ibuf[ibufcount++] = ch; | |||
| if (ibufcount == ibuf.length) { | |||
| ibufcount = 0; | |||
| obufcount += decode0(ibuf, obuf, obufcount); | |||
| } | |||
| } | |||
| if (obufcount == obuf.length) { | |||
| return obuf; | |||
| } | |||
| else { | |||
| byte ret[] = new byte[obufcount]; | |||
| System.arraycopy(obuf, 0, ret, 0, obufcount); | |||
| return ret; | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @param data | |||
| * @return | |||
| */ | |||
| public static byte[] decode(String data) { | |||
| char ibuf[] = new char[4]; | |||
| int ibufcount = 0; | |||
| byte obuf[] = new byte[(data.length() / 4) * 3 + 3]; | |||
| int obufcount = 0; | |||
| for (int i = 0; i < data.length(); i++) { | |||
| char ch = data.charAt(i); | |||
| if (ch != '=' && (ch >= S_DECODETABLE.length || S_DECODETABLE[ch] == 127)) | |||
| continue; | |||
| ibuf[ibufcount++] = ch; | |||
| if (ibufcount == ibuf.length) { | |||
| ibufcount = 0; | |||
| obufcount += decode0(ibuf, obuf, obufcount); | |||
| } | |||
| } | |||
| if (obufcount == obuf.length) { | |||
| return obuf; | |||
| } | |||
| else { | |||
| byte ret[] = new byte[obufcount]; | |||
| System.arraycopy(obuf, 0, ret, 0, obufcount); | |||
| return ret; | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @param data | |||
| * @param off | |||
| * @param len | |||
| * @param ostream | |||
| * @throws IOException | |||
| */ | |||
| public static void decode(char data[], int off, int len, OutputStream ostream) throws IOException { | |||
| char ibuf[] = new char[4]; | |||
| int ibufcount = 0; | |||
| byte obuf[] = new byte[3]; | |||
| for (int i = off; i < off + len; i++) { | |||
| char ch = data[i]; | |||
| if (ch != '=' && (ch >= S_DECODETABLE.length || S_DECODETABLE[ch] == 127)) | |||
| continue; | |||
| ibuf[ibufcount++] = ch; | |||
| if (ibufcount == ibuf.length) { | |||
| ibufcount = 0; | |||
| int obufcount = decode0(ibuf, obuf, 0); | |||
| ostream.write(obuf, 0, obufcount); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @param data | |||
| * @param ostream | |||
| * @throws IOException | |||
| */ | |||
| public static void decode(String data, OutputStream ostream) throws IOException { | |||
| char ibuf[] = new char[4]; | |||
| int ibufcount = 0; | |||
| byte obuf[] = new byte[3]; | |||
| for (int i = 0; i < data.length(); i++) { | |||
| char ch = data.charAt(i); | |||
| if (ch != '=' && (ch >= S_DECODETABLE.length || S_DECODETABLE[ch] == 127)) | |||
| continue; | |||
| ibuf[ibufcount++] = ch; | |||
| if (ibufcount == ibuf.length) { | |||
| ibufcount = 0; | |||
| int obufcount = decode0(ibuf, obuf, 0); | |||
| ostream.write(obuf, 0, obufcount); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @param data | |||
| * @return | |||
| */ | |||
| public static String encode(byte data[]) { | |||
| return encode(data, 0, data.length); | |||
| } | |||
| /** | |||
| * | |||
| * @param data | |||
| * @param off | |||
| * @param len | |||
| * @return | |||
| */ | |||
| public static String encode(byte data[], int off, int len) { | |||
| if (len <= 0) | |||
| return ""; | |||
| char out[] = new char[(len / 3) * 4 + 4]; | |||
| int rindex = off; | |||
| int windex = 0; | |||
| int rest; | |||
| for (rest = len - off; rest >= 3; rest -= 3) { | |||
| int i = ((data[rindex] & 255) << 16) + ((data[rindex + 1] & 255) << 8) + (data[rindex + 2] & 255); | |||
| out[windex++] = S_BASE64CHAR[i >> 18]; | |||
| out[windex++] = S_BASE64CHAR[i >> 12 & 63]; | |||
| out[windex++] = S_BASE64CHAR[i >> 6 & 63]; | |||
| out[windex++] = S_BASE64CHAR[i & 63]; | |||
| rindex += 3; | |||
| } | |||
| if (rest == 1) { | |||
| int i = data[rindex] & 255; | |||
| out[windex++] = S_BASE64CHAR[i >> 2]; | |||
| out[windex++] = S_BASE64CHAR[i << 4 & 63]; | |||
| out[windex++] = '='; | |||
| out[windex++] = '='; | |||
| } | |||
| else if (rest == 2) { | |||
| int i = ((data[rindex] & 255) << 8) + (data[rindex + 1] & 255); | |||
| out[windex++] = S_BASE64CHAR[i >> 10]; | |||
| out[windex++] = S_BASE64CHAR[i >> 4 & 63]; | |||
| out[windex++] = S_BASE64CHAR[i << 2 & 63]; | |||
| out[windex++] = '='; | |||
| } | |||
| return new String(out, 0, windex); | |||
| } | |||
| /** | |||
| * | |||
| * @param data | |||
| * @param off | |||
| * @param len | |||
| * @param ostream | |||
| * @throws IOException | |||
| */ | |||
| public static void encode(byte data[], int off, int len, OutputStream ostream) throws IOException { | |||
| if (len <= 0) | |||
| return; | |||
| byte out[] = new byte[4]; | |||
| int rindex = off; | |||
| int rest; | |||
| for (rest = len - off; rest >= 3; rest -= 3) { | |||
| int i = ((data[rindex] & 255) << 16) + ((data[rindex + 1] & 255) << 8) + (data[rindex + 2] & 255); | |||
| out[0] = (byte) S_BASE64CHAR[i >> 18]; | |||
| out[1] = (byte) S_BASE64CHAR[i >> 12 & 63]; | |||
| out[2] = (byte) S_BASE64CHAR[i >> 6 & 63]; | |||
| out[3] = (byte) S_BASE64CHAR[i & 63]; | |||
| ostream.write(out, 0, 4); | |||
| rindex += 3; | |||
| } | |||
| if (rest == 1) { | |||
| int i = data[rindex] & 255; | |||
| out[0] = (byte) S_BASE64CHAR[i >> 2]; | |||
| out[1] = (byte) S_BASE64CHAR[i << 4 & 63]; | |||
| out[2] = 61; | |||
| out[3] = 61; | |||
| ostream.write(out, 0, 4); | |||
| } | |||
| else if (rest == 2) { | |||
| int i = ((data[rindex] & 255) << 8) + (data[rindex + 1] & 255); | |||
| out[0] = (byte) S_BASE64CHAR[i >> 10]; | |||
| out[1] = (byte) S_BASE64CHAR[i >> 4 & 63]; | |||
| out[2] = (byte) S_BASE64CHAR[i << 2 & 63]; | |||
| out[3] = 61; | |||
| ostream.write(out, 0, 4); | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @param data | |||
| * @param off | |||
| * @param len | |||
| * @param writer | |||
| * @throws IOException | |||
| */ | |||
| public static void encode(byte data[], int off, int len, Writer writer) throws IOException { | |||
| if (len <= 0) | |||
| return; | |||
| char out[] = new char[4]; | |||
| int rindex = off; | |||
| int rest = len - off; | |||
| int output = 0; | |||
| do { | |||
| if (rest < 3) | |||
| break; | |||
| int i = ((data[rindex] & 255) << 16) + ((data[rindex + 1] & 255) << 8) + (data[rindex + 2] & 255); | |||
| out[0] = S_BASE64CHAR[i >> 18]; | |||
| out[1] = S_BASE64CHAR[i >> 12 & 63]; | |||
| out[2] = S_BASE64CHAR[i >> 6 & 63]; | |||
| out[3] = S_BASE64CHAR[i & 63]; | |||
| writer.write(out, 0, 4); | |||
| rindex += 3; | |||
| rest -= 3; | |||
| if ((output += 4) % 76 == 0) | |||
| writer.write("\n"); | |||
| } | |||
| while (true); | |||
| if (rest == 1) { | |||
| int i = data[rindex] & 255; | |||
| out[0] = S_BASE64CHAR[i >> 2]; | |||
| out[1] = S_BASE64CHAR[i << 4 & 63]; | |||
| out[2] = '='; | |||
| out[3] = '='; | |||
| writer.write(out, 0, 4); | |||
| } | |||
| else if (rest == 2) { | |||
| int i = ((data[rindex] & 255) << 8) + (data[rindex + 1] & 255); | |||
| out[0] = S_BASE64CHAR[i >> 10]; | |||
| out[1] = S_BASE64CHAR[i >> 4 & 63]; | |||
| out[2] = S_BASE64CHAR[i << 2 & 63]; | |||
| out[3] = '='; | |||
| writer.write(out, 0, 4); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,59 @@ | |||
| package com.iformall.utils; | |||
| import org.bouncycastle.jce.provider.BouncyCastleProvider; | |||
| import javax.crypto.Cipher; | |||
| import javax.crypto.spec.SecretKeySpec; | |||
| import java.security.Security; | |||
| public class CipherUtil { | |||
| /** | |||
| * 密钥算法 | |||
| */ | |||
| private static final String ALGORITHM = "AES"; | |||
| /** | |||
| * 加解密算法/工作模式/填充方式 | |||
| */ | |||
| private static final String ALGORITHM_MODE_PADDING = "AES/ECB/PKCS7Padding"; | |||
| static { | |||
| try { | |||
| Security.addProvider(new BouncyCastleProvider()); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| /** | |||
| * AES解密 | |||
| */ | |||
| public static String decryptData(byte[] b, String serectKey) throws Exception { | |||
| Cipher cipher = Cipher.getInstance(ALGORITHM_MODE_PADDING); | |||
| SecretKeySpec key = new SecretKeySpec(HashUtil.md5(serectKey).toLowerCase().getBytes(), ALGORITHM); | |||
| cipher.init(Cipher.DECRYPT_MODE, key); | |||
| return new String(cipher.doFinal(b)); | |||
| } | |||
| /** | |||
| * decryptReqInfo | |||
| * @param req_info | |||
| * @param key | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| public static String decryptReqInfo(String req_info, String key) throws Exception { | |||
| byte[] b = Base64Util.decode(req_info); | |||
| String B = decryptData(b, key); | |||
| return B; | |||
| } | |||
| public static void main(String[] args) throws Exception { | |||
| String A = "Ndaz8Fj4VUkxnD9iQ2ghD8yRgG8M9gBa0qIP4/GebJtzFWswbquDH/+kX3ZGB6zVb//4ZLIxMC4IZ0hzhsNc8JsDGbPKSYlaBI1prdbXr8YMzqAAHg+UJKNPyibJAV0o+soGNYeVrzVhzjWk0oFzCk2rvAtLlnq6RKjwTLOlIUxWXJMvtsCtpXKvcWMxRx+8pn42Barx6B2D0lM+39Vmi5Mu6XXHi9xUO+KPF7sgfv4hz/2NBBBfsR9Df0CxfQrEKmjxWgrl4Cn1g8JvBhZJiqUsP0oxS+xBZVGRLRY66oDNaLlNtzmwsrkEnDc1hWXgy3AymB0oLRz5SAOry0vKrzqv/yw1pWzyltAZ/M7ge6iD7gP/ILcxty5HjOZE22p01J6MqW8UAiTizrURucC/e3f9N935qs3DR8oqDO2Di4KR1pZnVQcxStnrlnq5YkaZRYXAdp3od80zCaNnNKxWuygxbJwkLOeohVaZNaCrBtxtvzZgHHiIrXSjAtHhXdxcl3A7Oo7M2I11D7Sss/BF72W8b0VgLY/GeJvUI5cmxpjMsE445coq7FQpAGZiLzohg73VpTA2GLxkev0xZj22XdKuJpl4SIOaSBxnDLTILzs/Ed6BndL3+jeep3eb2i5GbzREkdBlHUqxr7/ea9OeMZLVnLcWPmcDctDEQGObVQOlLD9KMUvsQWVRkS0WOuqAkQXAqvB5qhA48BZlHAitz7F2Q4+aAJx5KUFIkrxpYNMuoAvUBRA4HNaQz/metEA10EzVcTsuG2OCQmHsVIRqhMgbRz3a3xjTWMxN1KoHO8KaxEdN3CpXfXSNgMvEa/G4v6As59RnW5PRxUeqJSyfgMeoACdLb6tGwk8Jd72NPP8HMF4fUy8JqgtoOcm6UTBdcQHb/OVqQSDpWlNToOB9GdBM1XE7LhtjgkJh7FSEaoQ576jMlCjyCAqd+c3yiDBIrtaemJwBBhwHmnHMwYimTSDDzy4mbTZE41svWepZKmZcH/6+OM+d71UOiPaVQS6IJZhBCvKYLpbpu4+OjEUNGKE+8CpN5TcxfpQLR+6c/KZZjXSTeR4RK6I2yNW7yocy"; | |||
| String B = decryptReqInfo(A, "XHZfpVA0NzoXgLEjsujctUTcyj8Zur2C"); | |||
| System.out.println(B); | |||
| } | |||
| } | |||
| @@ -26,7 +26,7 @@ | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| @@ -163,7 +163,6 @@ | |||
| and co.coupon_id = c.id | |||
| and cu.id = co.c_user_id | |||
| and bu.id = co.b_user_id | |||
| and bu.status = 0 | |||
| <if test="startDate != null"> | |||
| AND co.update_date > #{startDate,jdbcType=TIMESTAMP} | |||
| </if> | |||
| @@ -21,11 +21,12 @@ | |||
| <result column="img_url_h" jdbcType="VARCHAR" property="imgUrlH" /> | |||
| <result column="wiwide_key" jdbcType="VARCHAR" property="wiwideKey" /> | |||
| <result column="wiwide_url" jdbcType="VARCHAR" property="wiwideUrl" /> | |||
| <result column="weap_note" jdbcType="VARCHAR" property="weapNote" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`,`wiwide_id`,`total_area`,`operating_area`,`park_area`,`park_place_number`,`pay_id`,`service_phone`,`img_url`,`img_url_h`,`wiwide_key`,`wiwide_url` | |||
| `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`,`wiwide_id`,`total_area`,`operating_area`,`park_area`,`park_place_number`,`pay_id`,`service_phone`,`img_url`,`img_url_h`,`wiwide_key`,`wiwide_url`, `weap_note` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||