| @@ -56,7 +56,7 @@ import java.util.concurrent.TimeUnit; | |||
| @RequestMapping("/wechat") | |||
| @Slf4j | |||
| public class WechatLoginController extends BaseController { | |||
| private String WECHAT_PREV = "OPEN-"; | |||
| private String WECHAT_PREV = "LOGIN:OPEN:"; | |||
| @Autowired | |||
| private WxMpService wxMpService; | |||
| @@ -84,7 +84,6 @@ public class WechatLoginController extends BaseController { | |||
| log.debug("[" + getIpAddr() + "] MallUserInfoController::login"); | |||
| String host = request.getHeader("host"); | |||
| log.debug("Host: " + host); | |||
| // host = getHost(host); | |||
| String wechatUrl = wxMpService.buildQrConnectUrl("https://"+host+"/api/wechat/callback", "snsapi_login", "111"); | |||
| try { | |||
| response.sendRedirect(wechatUrl); | |||
| @@ -93,22 +92,6 @@ public class WechatLoginController extends BaseController { | |||
| } | |||
| } | |||
| private String getHost(String host) { | |||
| if(host.contains("iformall.com")) { | |||
| if(host.contains("admintest")) { | |||
| host = "admin.malls.iformall.com"; | |||
| } else { | |||
| host = "admintest.malls.iformall.com"; | |||
| } | |||
| } else if(host.contains("youlane.cn")) { | |||
| host = "mall.youlane.cn"; | |||
| } else { | |||
| host = "admin.malls.iformall.com"; | |||
| } | |||
| return host; | |||
| } | |||
| @ApiOperation(value = "微信网页登录回调", notes = "请配置此callback到网页redirect_uri") | |||
| @GetMapping("callback") | |||
| public void getAccessToken(String code, String state, HttpServletRequest request, HttpServletResponse response) { | |||
| @@ -116,7 +99,6 @@ public class WechatLoginController extends BaseController { | |||
| String host = request.getHeader("host"); | |||
| log.debug("host: " + host); | |||
| log.debug("code: " + code); | |||
| // host = getHost(host); | |||
| try { | |||
| WxMpOAuth2AccessToken accessToken = wxMpService.oauth2getAccessToken(code); | |||
| log.info("accessToken: " + accessToken.getAccessToken() + ", openId: " + accessToken.getOpenId() + ", unionId: " + accessToken.getUnionId()); | |||
| @@ -207,14 +189,16 @@ public class WechatLoginController extends BaseController { | |||
| } | |||
| } else { | |||
| // 跳转登录选择页面 | |||
| String key = WECHAT_PREV + TOTP.generateWechatOpen(accessToken.getOpenId()); | |||
| String openId = accessToken.getOpenId(); | |||
| String key = TOTP.generateWechatOpen(openId); | |||
| String openKey = WECHAT_PREV + key; | |||
| Boolean isAbsent = openRedisTemplate.<Boolean>execute(new RedisCallback<Boolean>() { | |||
| @Override | |||
| public Boolean doInRedis(RedisConnection connection) throws DataAccessException { | |||
| RedisSerializer valueSerializer = openRedisTemplate.getValueSerializer(); | |||
| RedisSerializer keySerializer = openRedisTemplate.getKeySerializer(); | |||
| Object obj = connection.execute("set", keySerializer.serialize(key), | |||
| valueSerializer.serialize(key), | |||
| Object obj = connection.execute("set", keySerializer.serialize(openKey), | |||
| valueSerializer.serialize(openId), | |||
| SafeEncoder.encode("NX"), | |||
| SafeEncoder.encode("EX"), | |||
| Protocol.toByteArray(60)); // 60s 过期时间 | |||
| @@ -251,7 +235,6 @@ public class WechatLoginController extends BaseController { | |||
| log.error(e.getMessage()); | |||
| } | |||
| } | |||
| //return r; | |||
| } catch (WxErrorException e) { | |||
| log.error(e.getMessage()); | |||
| } | |||
| @@ -273,10 +256,11 @@ public class WechatLoginController extends BaseController { | |||
| String openKey = WECHAT_PREV + key; | |||
| // 限时时间内查找到此用户openId | |||
| if (openRedisTemplate.hasKey(WECHAT_PREV + key)){ | |||
| if (openRedisTemplate.hasKey(openKey)){ | |||
| log.info(openKey + " - 找不到"); | |||
| String openId = openRedisTemplate.opsForValue().get(openKey); | |||
| // 删除缓存 | |||
| openRedisTemplate.delete(openKey); | |||
| log.info("KEY: " + openKey + " deleted"); | |||
| MallUserInfo userInfo = mallUserInfoService.getByUsername(userName); | |||
| if(userInfo.getWebOpenId().equals(openId)) { | |||
| @@ -315,10 +299,11 @@ public class WechatLoginController extends BaseController { | |||
| } | |||
| } else { | |||
| // 登录失败 | |||
| log.error("微信登录失败,未找到对应的openId"); | |||
| return new ResultData(ErrorCode.WECHAT_LOGIN_KEY_OVERTIME); | |||
| log.error("微信登录失败,用户微信未绑定:" + openId); | |||
| return new ResultData(ErrorCode.WECHAT_LOGIN_NOT_BIND); | |||
| } | |||
| } | |||
| log.error("微信登录失败,KEY已过期: "+ key); | |||
| return new ResultData(ErrorCode.WECHAT_LOGIN_KEY_OVERTIME); | |||
| } | |||
| @@ -29,6 +29,15 @@ public class WxBillAllController extends BaseController | |||
| private Logger logger = LoggerFactory.getLogger(WxBillAllController.class); | |||
| @GetMapping("oweBillCount") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="contractId",value="合同id",dataType="long", paramType = "query",required=true), | |||
| @ApiImplicitParam(name="type",value="类型1租赁合同2物业合同",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData oweBillCount(Long contractId,Integer type) { | |||
| Long count = wxBillAllService.hasOweBill(contractId,type); | |||
| return new ResultData(count); | |||
| } | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||
| @@ -5,6 +5,7 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.enums.EnumMerchantPublic; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.utils.HashUtil; | |||
| @@ -39,6 +40,7 @@ public class WxMerchantController extends BaseController { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchantVo(); | |||
| wxMerchant.setMerchantStatus(EnumMerchantStatus.VALID.getCode()); | |||
| wxMerchant.setIsPublic(EnumMerchantPublic.PUBLIC.getCode()); | |||
| return new ResultData(wxMerchantService.listAsPageCVo(wxMerchant, pageNum, pageSize)); | |||
| } | |||
| @@ -2,10 +2,7 @@ package com.iformall.schedule; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import com.iformall.enums.EnumOrderType; | |||
| import com.iformall.enums.EnumRefundStatus; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.WxAppinfoMapper; | |||
| import com.iformall.mapper.WxOrderGroupMapper; | |||
| import com.iformall.mapper.WxOrderMapper; | |||
| @@ -29,7 +26,8 @@ import java.util.Map; | |||
| public class OrderExpiringSchedule { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private final int TIME_OUT_VALUE = 15 * 60 * 1000; //15分钟 | |||
| private final int NORMAL_TIME_OUT = 15 * 60 * 1000; //普通券 必须15分钟内支付 | |||
| private final int PRESS_TIME_OUT = 15 * 60 * 1000; //砍价券 必须60分钟内支付 | |||
| @Autowired | |||
| WxOrderMapper wxOrderMapper; | |||
| @@ -55,7 +53,7 @@ public class OrderExpiringSchedule { | |||
| Map dateMap = new HashMap(); | |||
| Date curDate = new Date(); | |||
| Date expireDate = new Date(curDate.getTime() - TIME_OUT_VALUE ); | |||
| Date expireDate = new Date(curDate.getTime() - NORMAL_TIME_OUT ); | |||
| // 券相关订单, 15分钟未支付, 订单过期 | |||
| dateMap.put("type", EnumOrderType.COUPON.getCode()); | |||
| @@ -65,19 +63,32 @@ public class OrderExpiringSchedule { | |||
| try { | |||
| orderExpired(o); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| logger.error("券过期失败" + e.getMessage()); | |||
| } | |||
| }); | |||
| // 砍价相关订单, 已超过砍价结束时间, 订单过期 | |||
| // 砍价相关订单, | |||
| // 1. 如果已经砍价完成,必须60分钟内支付, 未支付,订单过期 | |||
| Date pressExpireDate = new Date(curDate.getTime() - PRESS_TIME_OUT ); | |||
| dateMap.put("type", EnumOrderType.COUPON.getCode()); | |||
| dateMap.put("endDate", pressExpireDate); | |||
| List<WxOrder> orderPresss = wxOrderMapper.findListOfCompleteUnPaidPressOrderByDate(dateMap); | |||
| orderPresss.stream().forEach( o -> { | |||
| try { | |||
| orderPressExpired(o); | |||
| } catch (Exception e) { | |||
| logger.error("砍价券支付过期失败" + e.getMessage()); | |||
| } | |||
| }); | |||
| // 2. 当前已超过砍价结束时间, 订单过期 | |||
| dateMap.put("type", EnumOrderType.COUPON.getCode()); | |||
| dateMap.put("endDate", curDate); | |||
| List<WxOrder> orderPresss = wxOrderMapper.findListOfUnpaidPressOrderByDate(dateMap); | |||
| orderPresss = wxOrderMapper.findListOfUnpaidPressOrderByDate(dateMap); | |||
| orderPresss.stream().forEach( o -> { | |||
| try { | |||
| orderPressExpired(o); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| logger.error("砍价券过期失败" +e.getMessage()); | |||
| } | |||
| }); | |||
| @@ -131,9 +142,7 @@ public class OrderExpiringSchedule { | |||
| // 微信 关单 | |||
| wxOrderService.orderClose(updateOrder); | |||
| logger.info("\nFound " + order.getId() + "\n" | |||
| + " create at " + order.getCreateDate() +"\n" | |||
| + " expired at " + new Date()); | |||
| logger.info("券订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + new Date()); | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @@ -148,7 +157,7 @@ public class OrderExpiringSchedule { | |||
| // 库存退回 | |||
| wxOrderService.stockBack(order); | |||
| logger.info("\n砍价订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + curDate); | |||
| logger.info("砍价订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + curDate); | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @@ -1,11 +1,16 @@ | |||
| package com.iformall.domain.po; | |||
| import java.util.Map; | |||
| /** | |||
| * @author luozukai | |||
| * @date 2019/3/7 10:05 | |||
| */ | |||
| public class MailMsg extends BaseMsg { | |||
| private static final long serialVersionUID = 923764283760321L; | |||
| // 模板id | |||
| private Integer modelId; | |||
| private String tenantId; | |||
| private String[] to; | |||
| private String from; | |||
| @@ -21,6 +26,33 @@ public class MailMsg extends BaseMsg { | |||
| private String rscPath; | |||
| private String rscI; | |||
| //动态替换内容 | |||
| private Map<String,String> dynamicContentMap; | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String tenantId) { | |||
| this.tenantId = tenantId; | |||
| } | |||
| public Map<String, String> getDynamicContentMap() { | |||
| return dynamicContentMap; | |||
| } | |||
| public void setDynamicContentMap(Map<String, String> dynamicContentMap) { | |||
| this.dynamicContentMap = dynamicContentMap; | |||
| } | |||
| public Integer getModelId() { | |||
| return modelId; | |||
| } | |||
| public void setModelId(Integer modelId) { | |||
| this.modelId = modelId; | |||
| } | |||
| public String[] getTo() { | |||
| return to; | |||
| } | |||
| @@ -140,6 +140,9 @@ public class WxMerchant implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value = "类型", name = "type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否显示在C端", name = "isPublic") | |||
| private Integer isPublic; | |||
| public List<WxLevelConfig> getLevelConfigList() { | |||
| return levelConfigList; | |||
| } | |||
| @@ -377,6 +380,14 @@ public class WxMerchant implements Serializable { | |||
| this.type = type; | |||
| } | |||
| public Integer getIsPublic() { | |||
| return isPublic; | |||
| } | |||
| public void setIsPublic(Integer isPublic) { | |||
| this.isPublic = isPublic; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| @@ -1,7 +1,5 @@ | |||
| package com.iformall.domain.vo; | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
| import javax.persistence.Id; | |||
| public class WxMerchantVo { | |||
| private static final long serialVersionUID = 6687964942922444531L; | |||
| @@ -52,6 +50,16 @@ public class WxMerchantVo { | |||
| @io.swagger.annotations.ApiModelProperty(value="楼层",name="floorName") | |||
| private String floorName; | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否显示在C端", name = "show") | |||
| private Integer isPublic; | |||
| public Integer getIsPublic() { | |||
| return isPublic; | |||
| } | |||
| public void setIsPublic(Integer isPublic) { | |||
| this.isPublic = isPublic; | |||
| } | |||
| public String getBuildingName() {return buildingName; } | |||
| public void setBuildingName(String _building) { | |||
| @@ -0,0 +1,35 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumMerchantPublic { | |||
| PUBLIC(1, "公开"), | |||
| PRIVATE(0, "私有"),; | |||
| public static EnumMerchantPublic getEnum(Integer code) { | |||
| for (EnumMerchantPublic value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumMerchantPublic(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -33,4 +33,6 @@ public interface WxBillPropertyMapper extends CommonMapper<WxBillProperty, Long> | |||
| void update(WxBillProperty wxBillProperty); | |||
| void updatePreviewStatus(WxBillProperty record); | |||
| Long oweBillCount(Long contractId); | |||
| } | |||
| @@ -29,4 +29,6 @@ public interface WxBillRentMapper extends CommonMapper<WxBillRent, Long> { | |||
| void update(WxBillRent record); | |||
| void updatePreviewStatus(WxBillRent record); | |||
| Long oweBillCount(Long contractId); | |||
| } | |||
| @@ -7,9 +7,9 @@ import com.iformall.domain.po.WxMsgModel; | |||
| public interface WxMsgModelMapper extends CommonMapper<WxMsgModel, String> { | |||
| List<WxMsgModel> findList(WxMsgModel wxMsgModel); | |||
| WxMsgModel findOneByModelId(WxMsgModel wxMsgModel); | |||
| @@ -15,7 +15,9 @@ public interface WxOrderMapper extends CommonMapper<WxOrder, Long> { | |||
| Integer countList(WxOrder wxOrder); | |||
| List<WxOrder> findListOfUnpaidOrderByDate(Map dateMap); | |||
| List<WxOrder> findListOfUnpaidPressOrderByDate(Map dateMap); | |||
| List<WxOrder> findListOfCompleteUnPaidPressOrderByDate(Map dateMap); | |||
| List<WxOrderCouponVo> findListOfCUser(WxOrder wxOrder); | |||
| WxOrderCouponVo selectDetailOfCUser(WxOrder wxOrder); | |||
| @@ -24,4 +24,6 @@ public interface WxBillAllService { | |||
| void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillAll wxBillAll); | |||
| Object getBillInfo(WxBillAll wxBillAll); | |||
| Long hasOweBill(Long contractId,Integer type); | |||
| } | |||
| @@ -24,7 +24,7 @@ import java.util.Map; | |||
| public class PushLimitServiceImpl implements PushLimitService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private String keyPrev = "pushlimit_"; | |||
| private String keyPrev = "setting:pushlimit:"; | |||
| @Autowired | |||
| PushLimitMapper pushLimitMapper; | |||
| @@ -2,6 +2,8 @@ package com.iformall.service.impl; | |||
| import com.iformall.domain.po.BaseMsg; | |||
| import com.iformall.domain.po.MailMsg; | |||
| import com.iformall.domain.po.WxMsgModel; | |||
| import com.iformall.mapper.WxMsgModelMapper; | |||
| import com.iformall.service.MsgSendService; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| @@ -15,6 +17,7 @@ import org.springframework.mail.javamail.MimeMessageHelper; | |||
| import org.springframework.stereotype.Service; | |||
| import javax.mail.internet.MimeMessage; | |||
| import java.io.File; | |||
| import java.util.Map; | |||
| /** | |||
| * 发送邮件 | |||
| @@ -31,9 +34,28 @@ public class SendEmailServiceImpl implements MsgSendService { | |||
| @Value("${spring.mail.username}") | |||
| private String from; | |||
| @Autowired | |||
| private WxMsgModelMapper wxMsgModelMapper; | |||
| @Override | |||
| public void send(BaseMsg baseMsg) throws Exception{ | |||
| MailMsg mailMsg = (MailMsg)baseMsg; | |||
| //根据模板替换动态内容 | |||
| if(mailMsg.getModelId() != null){ | |||
| WxMsgModel msgModel = new WxMsgModel(); | |||
| msgModel.setTenantId(mailMsg.getTenantId()); | |||
| msgModel.setModelId(mailMsg.getModelId()); | |||
| WxMsgModel wxMsgModel = wxMsgModelMapper.findOneByModelId(msgModel); | |||
| if(wxMsgModel == null){ | |||
| throw new Exception("模板id:"+mailMsg.getModelId()+"不存在"); | |||
| } | |||
| String msg = wxMsgModel.getContent(); | |||
| for (Map.Entry<String, String> entry : mailMsg.getDynamicContentMap().entrySet()) { | |||
| msg = msg.replace("{"+entry.getKey()+"}", entry.getValue()); | |||
| } | |||
| mailMsg.setMsg(msg); | |||
| } | |||
| if(mailMsg.isHtml()){ //html邮件 | |||
| MimeMessage message = sender.createMimeMessage(); | |||
| @@ -515,4 +515,14 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| result.put("paidInfoForPoint", paidInfoForPoint); | |||
| return result; | |||
| } | |||
| @Override | |||
| public Long hasOweBill(Long contractId, Integer type) { | |||
| if(type.intValue() == 1){ | |||
| return wxBillRentMapper.oweBillCount(contractId); | |||
| }else if(type.intValue() == 2){ | |||
| return wxBillPropertyMapper.oweBillCount(contractId); | |||
| } | |||
| return 0l; | |||
| } | |||
| } | |||
| @@ -189,6 +189,7 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { | |||
| return new ResultData(ErrorCode.BILL_RENT_DEPOSIT_IS_NOT_FOUND); | |||
| } | |||
| wxBillDeposit.setReceivePay(record.getReceivePay()); | |||
| wxBillDeposit.setOwe(record.getReceivePay() - record.getPay()); | |||
| wxBillDeposit.setUpdatetime(new Date()); | |||
| try { | |||
| wxBillDepositMapper.updateByPrimaryKeySelective(wxBillDeposit); | |||
| @@ -207,6 +207,7 @@ public class WxBillOtherDepositServiceImpl implements WxBillOtherDepositService | |||
| return new ResultData(ErrorCode.BILL_OTHER_DEPOSIT_IS_NOT_FOUND); | |||
| } | |||
| wxBillDeposit.setReceivePay(record.getReceivePay()); | |||
| wxBillDeposit.setOwe(record.getReceivePay() - record.getPay()); | |||
| wxBillDeposit.setUpdatetime(new Date()); | |||
| try { | |||
| wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillDeposit); | |||
| @@ -190,6 +190,7 @@ public class WxBillPropertyDepositServiceImpl implements WxBillPropertyDepositSe | |||
| return new ResultData(ErrorCode.BILL_OTHER_DEPOSIT_IS_NOT_FOUND); | |||
| } | |||
| wxBillDeposit.setReceivePay(record.getReceivePay()); | |||
| wxBillDeposit.setOwe(record.getReceivePay() - record.getPay()); | |||
| wxBillDeposit.setUpdatetime(new Date()); | |||
| try { | |||
| wxBillPropertyDepositMapper.updateByPrimaryKeySelective(wxBillDeposit); | |||
| @@ -27,6 +27,8 @@ import java.util.concurrent.TimeUnit; | |||
| public class WxCUserServiceImpl implements WxCUserService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private String tokenPrev = "weapp:token:"; | |||
| @Autowired | |||
| WxCUserMapper wxCUserMapper; | |||
| @@ -66,7 +68,7 @@ public class WxCUserServiceImpl implements WxCUserService { | |||
| @Override | |||
| public WxCUser getByToken(String token) { | |||
| logger.info("获取用户信息start ..."); | |||
| String key = "token_" + token; | |||
| String key = tokenPrev + token; | |||
| ValueOperations<String, WxCUser> operations = cUserTokenRedisTemplate.opsForValue(); | |||
| // 缓存 | |||
| @@ -99,7 +101,7 @@ public class WxCUserServiceImpl implements WxCUserService { | |||
| user.setUpdateDate(curr); | |||
| ret = wxCUserMapper.updateByPrimaryKeySelective(user); | |||
| } | |||
| String key = "token_" + user.getToken(); | |||
| String key = tokenPrev + user.getToken(); | |||
| // 缓存已存在,删除 | |||
| boolean hasKey = cUserTokenRedisTemplate.hasKey(key); | |||
| if(hasKey) { | |||
| @@ -73,7 +73,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| if (StringUtils.isEmpty(startdate)) { | |||
| startdate = DateUtils.getSystemTime("yyyy-MM-dd") + " 00:00:00" ; | |||
| } | |||
| if(StringUtils.isBlank(enddate)){ | |||
| if (StringUtils.isEmpty(enddate)) { | |||
| enddate = DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59"; | |||
| } | |||
| @@ -1470,19 +1470,22 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| WxCoupon wxCoupon = new WxCoupon(); | |||
| //默认时间本月第一天,截止到当天 | |||
| if(paramsMap.get("startdate") == null || StringUtils.isBlank(paramsMap.get("startdate"))){ | |||
| if (StringUtils.isEmpty(paramsMap.get("startdate"))) { | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH,1); | |||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||
| c.set(Calendar.MINUTE, 0); | |||
| c.set(Calendar.SECOND, 0); | |||
| wxCoupon.setStartdate(c.getTime()); | |||
| }else{ | |||
| Date startTime = DateUtils.stringToDate(startdate); | |||
| wxCoupon.setStartdate(startTime); | |||
| } | |||
| if(paramsMap.get("enddate") == null || StringUtils.isBlank(paramsMap.get("enddate"))){ | |||
| wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | |||
| if (StringUtils.isEmpty(paramsMap.get("enddate"))) { | |||
| wxCoupon.setEnddate(new Date()); | |||
| }else{ | |||
| Date endTime = DateUtils.stringToDate(enddate); | |||
| Date endTime = DateUtils.stringToDate(enddate, "yyyy-MM-dd HH:mm:ss"); | |||
| wxCoupon.setEnddate(endTime); | |||
| } | |||
| @@ -1512,19 +1515,22 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| Map<String,Object> result = new HashedMap(); | |||
| //默认时间本月第一天,截止到当天 | |||
| if(paramsMap.get("startdate") == null || StringUtils.isBlank(paramsMap.get("startdate"))){ | |||
| if (StringUtils.isEmpty(paramsMap.get("startdate"))) { | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH,1); | |||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||
| c.set(Calendar.MINUTE, 0); | |||
| c.set(Calendar.SECOND, 0); | |||
| wxCoupon.setStartdate(c.getTime()); | |||
| }else{ | |||
| Date startTime = DateUtils.stringToDate(startdate); | |||
| wxCoupon.setStartdate(startTime); | |||
| } | |||
| if(paramsMap.get("enddate") == null || StringUtils.isBlank(paramsMap.get("enddate"))){ | |||
| wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | |||
| if (StringUtils.isEmpty(paramsMap.get("enddate"))) { | |||
| wxCoupon.setEnddate(new Date()); | |||
| }else{ | |||
| Date endTime = DateUtils.stringToDate(enddate); | |||
| Date endTime = DateUtils.stringToDate(enddate, "yyyy-MM-dd HH:mm:ss"); | |||
| wxCoupon.setEnddate(endTime); | |||
| } | |||
| List<WxCoupon> orderCountList = wxCouponService.findCouponOrderCount(wxCoupon); | |||
| @@ -1566,19 +1572,22 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| Map<String,Object> result = new HashedMap(); | |||
| //默认时间本月第一天,截止到当天 | |||
| if(paramsMap.get("startdate") == null || StringUtils.isBlank(paramsMap.get("startdate"))){ | |||
| if (StringUtils.isEmpty(paramsMap.get("startdate"))) { | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH,1); | |||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||
| c.set(Calendar.MINUTE, 0); | |||
| c.set(Calendar.SECOND, 0); | |||
| wxCoupon.setStartdate(c.getTime()); | |||
| }else{ | |||
| Date startTime = DateUtils.stringToDate(startdate); | |||
| wxCoupon.setStartdate(startTime); | |||
| } | |||
| if(paramsMap.get("enddate") == null || StringUtils.isBlank(paramsMap.get("enddate"))){ | |||
| wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | |||
| if (StringUtils.isEmpty(paramsMap.get("enddate"))) { | |||
| wxCoupon.setEnddate(new Date()); | |||
| }else{ | |||
| Date endTime = DateUtils.stringToDate(enddate); | |||
| Date endTime = DateUtils.stringToDate(enddate, "yyyy-MM-dd HH:mm:ss"); | |||
| wxCoupon.setEnddate(endTime); | |||
| } | |||
| List<WxCoupon> pressSendHistory = wxCouponService.pressSendHistory(wxCoupon); | |||
| @@ -1615,21 +1624,23 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| Map<String, Object> result = new HashMap<>(); | |||
| Date startTime = new Date(); | |||
| Date endTime = startTime; | |||
| if (paramsMap.get("startdate") == null || StringUtils.isBlank(paramsMap.get("startdate"))) { | |||
| if (StringUtils.isEmpty(paramsMap.get("startdate"))) { | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH, 1); | |||
| c.set(Calendar.HOUR_OF_DAY, 0); | |||
| c.set(Calendar.MINUTE, 0); | |||
| c.set(Calendar.SECOND, 0); | |||
| startTime = c.getTime(); | |||
| params.put("startdate", startTime); | |||
| } else { | |||
| startTime = DateUtils.stringToDate(startdate + " 00:00:00"); | |||
| params.put("startdate", startTime); | |||
| } | |||
| if (paramsMap.get("enddate") == null || StringUtils.isBlank(paramsMap.get("enddate"))) { | |||
| if (StringUtils.isEmpty(paramsMap.get("enddate"))) { | |||
| params.put("enddate", endTime); | |||
| } else { | |||
| endTime = DateUtils.stringToDate(enddate + " 23:59:59"); | |||
| params.put("enddate", endTime); | |||
| params.put("enddate", paramsMap.get("enddate") + " 23:59:59"); | |||
| } | |||
| List<Map<String, Object>> successlist = wxOrderGroupMapper.queryOrderGroupSuccessCountAndTime(params); | |||
| @@ -1765,6 +1776,8 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| calBegin.setTime(begin); | |||
| Calendar calEnd = Calendar.getInstance(); | |||
| calEnd.setTime(end); | |||
| calEnd.add(Calendar.DAY_OF_MONTH, -1); | |||
| end = calEnd.getTime(); | |||
| while (calBegin.getTime().before(end)) { | |||
| calBegin.add(Calendar.DAY_OF_MONTH, 1); | |||
| map.put(format.format(calBegin.getTime()), 0L); | |||
| @@ -532,6 +532,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| if (wxMerchant.getId() == null) { | |||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| } | |||
| wxMerchantMapper.updateByPrimaryKeySelective(wxMerchant); | |||
| wxLevelConfigService.batchSaveByMerchantId(wxMerchant.getTenantId(), wxMerchant.getId(), wxMerchant.getLevelConfigList()); | |||
| } catch (Exception e) { | |||
| logger.error("db failed: 账号操作失败, e:" + e.getMessage()); | |||
| @@ -9,7 +9,6 @@ import com.iformall.domain.po.WxMsgConfig; | |||
| import com.iformall.domain.po.WxMsgModel; | |||
| import com.iformall.domain.po.WxMsgValidationcodeModel; | |||
| import com.iformall.enums.EnumMsgSendStatus; | |||
| import com.iformall.enums.EnumMsgStatus; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxMsgCallbackService; | |||
| import com.iformall.utils.HMACSHA256; | |||
| @@ -163,8 +162,9 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||
| sb.append(entry.getKey()).append("=").append(entry.getValue()); | |||
| } | |||
| sb.append("&secret=").append(wxMsgConfig.getSecret()); | |||
| logger.info("message:" + sb.toString() + ",secret:" + wxMsgConfig.getSecret()); | |||
| String sign_check = HMACSHA256.sha256_HMAC(sb.toString(), wxMsgConfig.getSecret()); | |||
| logger.info("sign_check:" + sign_check); | |||
| return sign_check.equalsIgnoreCase(param.get("sign")); | |||
| } | |||
| @@ -26,7 +26,7 @@ import java.util.List; | |||
| public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private String keyPrev = "scorerules_"; | |||
| private String keyPrev = "setting:scorerules:"; | |||
| @Autowired | |||
| WxScoreRulesMapper wxScoreRulesMapper; | |||
| @@ -186,7 +186,7 @@ | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type | |||
| from wx_bill_other | |||
| union | |||
| select id,merchant_id,shop_id,tenant_id,name,8 bill_type_value,'其他押金' bill_type,0 as | |||
| select id,merchant_id,shop_id,tenant_id,comments as name,8 bill_type_value,'其他押金' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type | |||
| from wx_bill_other_deposit | |||
| ) bill | |||
| @@ -131,7 +131,7 @@ | |||
| <update id="updateInvalidStatusByRent" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| update wx_bill_property set status = 6 where property_contract_id in | |||
| (select id from wx_property_contract where rent_contract_id = #{id}) | |||
| and status in(4,2) | |||
| and status != 3 | |||
| </update> | |||
| <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| @@ -148,4 +148,10 @@ | |||
| update wx_bill_property set is_preview = #{isPreview},merchant_id = #{merchantId} | |||
| where property_contract_id = #{propertyContractId} | |||
| </update> | |||
| <select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long"> | |||
| select count(br.id) from wx_bill_property br,wx_property_contract c | |||
| where c.id = br.property_contract_id and br.status = 1 and c.id = #{contractId} | |||
| </select> | |||
| </mapper> | |||
| @@ -127,7 +127,7 @@ | |||
| <update id="updateInvalidStatus" parameterType="com.iformall.domain.po.WxBillRent"> | |||
| update wx_bill_rent set status = 6 where rent_contract_id = #{rentContractId} | |||
| and status in(4,2) | |||
| and status != 3 | |||
| </update> | |||
| <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| @@ -144,4 +144,10 @@ | |||
| update wx_bill_rent set is_preview = #{isPreview},merchant_id = #{merchantId} | |||
| where rent_contract_id = #{rentContractId} | |||
| </update> | |||
| <select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long"> | |||
| select count(br.id) from wx_bill_rent br,wx_rent_contract c where c.id = br.rent_contract_id | |||
| and br.status = 1 and c.id = #{contractId} | |||
| </select> | |||
| </mapper> | |||
| @@ -713,11 +713,10 @@ | |||
| </select> | |||
| <select id="findSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long"> | |||
| select sum(subsidy_num) from wx_coupon c | |||
| select sum(sc.subsidy) from wx_card_info ci | |||
| left join wx_coupon c on c.id = ci.coupon_id | |||
| left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id | |||
| where c.type = 100 and c.create_date between #{startdate} and #{enddate} | |||
| <if test="id != null"> | |||
| and c.id = #{id} | |||
| </if> | |||
| </select> | |||
| <select id="findCountData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap"> | |||
| @@ -872,9 +871,10 @@ | |||
| </select> | |||
| <select id="findSumSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long"> | |||
| select sum(c.subsidy_num) from wx_coupon c,wx_coupon_order wco | |||
| where wco.coupon_id = c.id | |||
| and wco.create_date between #{startdate} and #{enddate} | |||
| select sum(sc.subsidy) from wx_coupon c | |||
| left join wx_coupon_order wo on wo.coupon_id = c.id | |||
| left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id | |||
| where c.type not in(8,9,100) and c.create_date between #{startdate} and #{enddate} | |||
| </select> | |||
| @@ -17,12 +17,13 @@ | |||
| <result column="shop_type" jdbcType="INTEGER" property="shopType"/> | |||
| <result column="brand" jdbcType="VARCHAR" property="brand"/> | |||
| <result column="type" jdbcType="SMALLINT" property="type"/> | |||
| <result column="is_public" jdbcType="SMALLINT" property="isPublic"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person`, | |||
| `business_id`,`shop_type`,`brand`,`type` | |||
| `business_id`,`shop_type`,`brand`,`type`,`is_public` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -75,6 +76,9 @@ | |||
| </if> | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != isPublic "> | |||
| and `is_public` = #{isPublic} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| @@ -96,7 +100,7 @@ | |||
| m.id, | |||
| m.img_url,m.name,m.link_phone,m.status,m.business_id, | |||
| s.addr,s.shop_number,s.baidu_poi, | |||
| mb.building_name,mf.floor_name | |||
| mb.building_name,mf.floor_name,m.is_public | |||
| </sql> | |||
| <resultMap id="MerchantVoResultMap" type="com.iformall.domain.vo.WxMerchantVo"> | |||
| @@ -111,6 +115,7 @@ | |||
| <result column="building_name" jdbcType="VARCHAR" property="buildingName"/> | |||
| <result column="floor_name" jdbcType="VARCHAR" property="floorName"/> | |||
| <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/> | |||
| <result column="is_public" jdbcType="SMALLINT" property="isPublic"/> | |||
| </resultMap> | |||
| @@ -172,6 +177,11 @@ | |||
| <if test=" null != floorName and ''!=floorName "> | |||
| and mf.`floor_name` like concat('%', #{floorName},'%') | |||
| </if> | |||
| <if test=" null != isPublic"> | |||
| and m.`is_public` = #{isPublic} | |||
| </if> | |||
| </select> | |||
| @@ -72,10 +72,20 @@ | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findOneByModelId" parameterType="com.iformall.domain.po.WxMsgModel" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_msg_model | |||
| where 1=1 | |||
| <if test=" null != modelId"> | |||
| and `model_id` = #{modelId} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id`=#{tenantId} | |||
| </if> | |||
| limit 1 | |||
| </select> | |||
| </mapper> | |||
| @@ -99,29 +99,20 @@ | |||
| <select id="queryOrderGroupMarketingList" parameterType="com.iformall.domain.vo.WxOrderGroupMarketing" | |||
| resultType="com.iformall.domain.vo.WxOrderGroupMarketing"> | |||
| select c.tenant_id,coupon_id,c.cover_img,title,c.price,c.sale_price,c.group_total_count,c.group_success_count, | |||
| ROUND(IFNULL((c.group_success_count/c.group_total_count),0)*100) | |||
| CONCAT(ROUND(IFNULL((c.group_success_count/c.group_total_count),0)*100),'%') | |||
| group_transfer_ratio,c.success_people,c.verify_count, | |||
| ROUND(IFNULL((verify_count/success_people),0)*100) verify_ratio,c.total_people from( | |||
| CONCAT(ROUND(IFNULL((verify_count/success_people),0)*100),'%') verify_ratio,c.total_people from( | |||
| select tenant_id,id coupon_id,cover_img,title,FORMAT(price/100,2) price,FORMAT(sale_price/100,2) sale_price, | |||
| (select count(*) total from wx_order_group where coupon_id=c.id) group_total_count, | |||
| (select count(*) total from wx_order_group where status=11 and coupon_id=c.id) group_success_count, | |||
| IFNULL((select success.total from ( | |||
| select count(success.product_id) total,success.product_id from ( | |||
| select product_id,c_user_id from wx_order | |||
| where order_status=11 | |||
| group by product_id,c_user_id) success | |||
| group by success.product_id) success where success.product_id=c.id),0) success_people, | |||
| IFNULL((select count(*) from wx_order where order_status=11 and product_id=c.id),0) success_people, | |||
| (select count(*) total | |||
| from wx_coupon_order where coupon_type=9 and coupon_order_status=1 and coupon_id=c.id) verify_count, | |||
| IFNULL((select success.total from ( | |||
| select count(success.product_id) total,success.product_id from ( | |||
| select product_id,c_user_id from wx_order | |||
| group by product_id,c_user_id) success | |||
| group by success.product_id) success where success.product_id=c.id),0) total_people | |||
| from wx_coupon c where type=9 | |||
| IFNULL((select count(*) from wx_order where order_group_id!=0 and product_id=c.id),0) total_people | |||
| from wx_coupon c where type=9 order by c.status,c.id desc | |||
| ) c | |||
| <where> | |||
| <if test=" null != couponId "> | |||
| <if test=" null != couponId and ''!=couponId"> | |||
| and c.coupon_id=#{couponId} | |||
| </if> | |||
| </where> | |||
| @@ -180,7 +171,7 @@ | |||
| </select> | |||
| <select id="queryOrderGroupPeopleCount" parameterType="hashmap" resultType="long"> | |||
| select count(*) from (select DISTINCT c_user_id from wx_order where order_group_id!=0 | |||
| select count(*) from (select id from wx_order where order_group_id!=0 | |||
| <if test=" null != tenantId"> | |||
| and tenant_id=#{tenantId} | |||
| </if> | |||
| @@ -164,6 +164,22 @@ | |||
| </if> | |||
| </select> | |||
| <select id="findListOfCompleteUnPaidPressOrderByDate" parameterType="map" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_order | |||
| where press_end_date is not null and order_status = 7 | |||
| <if test="type != null"> | |||
| AND type = #{type,jdbcType=TINYINT} | |||
| </if> | |||
| <if test="startDate != null"> | |||
| AND unix_timestamp(`create_date`) > unix_timestamp(#{startDate,jdbcType=TIMESTAMP}) | |||
| </if> | |||
| <if test="endDate != null"> | |||
| AND unix_timestamp(`update_date`) < unix_timestamp(#{endDate,jdbcType=TIMESTAMP}) | |||
| </if> | |||
| </select> | |||
| <sql id="allCUserOrderListColumns"> | |||
| o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date, | |||