| | |
| | | GROUP_PURCHASES_END_TASK("团购商品延时任务", "团购商品定时结束任务"), |
| | | AUCTION_GOODS_START_TASK("拍卖商品延时任务", "拍卖商品定时开始任务"), |
| | | AUCTION_GOODS_END_TASK("拍卖商品延时任务", "拍卖商品定时结束任务"), |
| | | |
| | | AUTOMATIC_CANCEL("用户秒杀推送消息", "用户秒杀推送消息"), |
| | | ; |
| | | |
| | | String name; |
| | |
| | | |
| | | @ApiModelProperty("拍卖会id") |
| | | private Long auctionSalesroomId; |
| | | @ApiModelProperty("是否显示订单 1显示,2 不显示") |
| | | private Integer isOrder; |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<?> GroupPurchaseNum(Long groupPurchaseId, String source) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R<?> GroupPurchaseNum1(Long groupPurchaseId, String source) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R<?> startSeckill(Long seckillId, String source) { |
| | | return R.fail("开始秒杀失败:" + cause.getMessage()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<?> tusonUser(Long tusonUserIdId, String source) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R<?> endGroupPurchase(Long groupPurchaseId, String source) { |
| | | return R.fail("结束团购失败:" + cause.getMessage()); |
| | | } |
| | |
| | | R<Boolean> updGoodsSeckill1(@RequestBody GoodsSku goodsSku, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | | |
| | | @GetMapping("/goods-group-purchase/num/{groupPurchaseId}") |
| | | R<?> GroupPurchaseNum(@PathVariable("groupPurchaseId") Long groupPurchaseId, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | | |
| | | @GetMapping("/goods-group-purchase/num1/{groupPurchaseId}") |
| | | R<?> GroupPurchaseNum1(@PathVariable("groupPurchaseId") Long groupPurchaseId, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | | |
| | | |
| | | @GetMapping("/goods-seckill/start/{seckillId}") |
| | | R<?> startSeckill(@PathVariable("seckillId") Long seckillId, |
| | |
| | | R<?> startGroupPurchase(@PathVariable("groupPurchaseId") Long groupPurchaseId, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | | |
| | | @GetMapping("/member-goods-collection/tusonUser/{tusonUserId}") |
| | | R<?> tusonUser(@PathVariable("tusonUserId") Long tusonUserIdId, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | | @GetMapping("/goods-group-purchase/end/{groupPurchaseId}") |
| | | R<?> endGroupPurchase(@PathVariable("groupPurchaseId") Long groupPurchaseId, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | |
| | | List<OrderAuctionBond> data = orderClient.getAuctionGoodsOrderAuctionBondList(auctionGoodsListDTO, SecurityConstants.INNER).getData(); |
| | | Set<Long> goodsSkuIdList = null; |
| | | if (data.size()>0){ |
| | | goodsSkuIdList = data.stream().map(OrderAuctionBond::getAuctionSalesroomId) |
| | | goodsSkuIdList = data.stream().map(OrderAuctionBond::getAuctionGoodsId) |
| | | .collect(Collectors.toSet()); |
| | | }else { |
| | | Set<Long> goodsSkuIdList1 =new HashSet<>(); |
| | |
| | | } |
| | | |
| | | if (auctionGoodsListDTO.getStartStatus()!=4){ |
| | | if (auctionGoodsListDTO.getStartStatus()==0){ |
| | | auctionGoodsListPageDTO.setStartStatus(5); |
| | | }else{ |
| | | auctionGoodsListPageDTO.setStartStatus(auctionGoodsListDTO.getStartStatus()); |
| | | } |
| | | |
| | | } |
| | | |
| | | Page<AuctionGoodsListVO> page = new Page<>(); |
| | | page.setSize(auctionGoodsListDTO.getPageSize()); |
| | | page.setCurrent(auctionGoodsListDTO.getPageCurr()); |
| | |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-httpclient</groupId> |
| | | <artifactId>commons-httpclient</artifactId> |
| | | <version>3.1</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alipay.sdk</groupId> |
| | | <artifactId>alipay-sdk-java</artifactId> |
| | | <version>4.39.95.ALL</version> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-spring-boot-starter</artifactId> |
| | | <version>4.0.0</version> |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @InnerAuth |
| | | @GetMapping("/num/{groupPurchaseId}") |
| | | R<?> GroupPurchaseNum(@PathVariable("groupPurchaseId") Long groupPurchaseId) { |
| | | try { |
| | | GoodsGroupPurchase byId = goodsGroupPurchaseService.getById(groupPurchaseId); |
| | | Integer m= byId.getCurrentNumber()+1; |
| | | byId.setCurrentNumber(m); |
| | | goodsGroupPurchaseService.updateById(byId); |
| | | } catch (Exception e) { |
| | | log.error("团购商品开始团购失败", e); |
| | | return R.fail("团购商品开始团购失败"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @InnerAuth |
| | | @GetMapping("/num1/{groupPurchaseId}") |
| | | R<?> GroupPurchaseNum1(@PathVariable("groupPurchaseId") Long groupPurchaseId) { |
| | | try { |
| | | GoodsGroupPurchase byId = goodsGroupPurchaseService.getById(groupPurchaseId); |
| | | Integer m= byId.getCurrentNumber()-1; |
| | | byId.setCurrentNumber(m); |
| | | goodsGroupPurchaseService.updateById(byId); |
| | | } catch (Exception e) { |
| | | log.error("团购商品开始团购失败", e); |
| | | return R.fail("团购商品开始团购失败"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 团购商品结束团购 |
| | | * |
| | |
| | | package com.ruoyi.goods.controller.inner; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import cn.binarywang.wx.miniapp.api.WxMaService; |
| | | import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; |
| | | import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; |
| | | import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; |
| | | import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.CertAlipayRequest; |
| | | import com.alipay.api.AlipayConfig; |
| | | import com.alipay.api.domain.AlipayOpenAppMiniTemplatemessageSendModel; |
| | | import com.alipay.api.response.AlipayOpenAppMiniTemplatemessageSendResponse; |
| | | import com.alipay.api.request.AlipayOpenAppMiniTemplatemessageSendRequest; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.annotation.InnerAuth; |
| | | import com.ruoyi.goods.domain.GoodsSeckillAppointment; |
| | | import com.ruoyi.goods.domain.MemberGoodsCollection; |
| | | import com.ruoyi.goods.mapper.GoodsSeckillMapper; |
| | | import com.ruoyi.goods.mapper.GoodsSkuMapper; |
| | | import com.ruoyi.goods.service.IGoodsSeckillAppointmentService; |
| | | import com.ruoyi.goods.service.IMemberGoodsCollectionService; |
| | | import com.ruoyi.goods.service.impl.MemberGoodsCollectionServiceImpl; |
| | | import com.ruoyi.goods.utli.HttpUtils; |
| | | import com.ruoyi.system.api.domain.GoodsSeckill; |
| | | import com.ruoyi.system.api.domain.GoodsSku; |
| | | import com.ruoyi.system.api.domain.Member; |
| | | import com.ruoyi.system.api.feignClient.MemberClient; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/member-goods-collection") |
| | | public class MemberGoodsCollectionController { |
| | | |
| | | private static final String ACCESS_TOKEN_HOST = "https://api.weixin.qq.com/cgi-bin/token"; |
| | | |
| | | private static final String WX_APPID = "wx69e3ac6e13a889b7"; |
| | | |
| | | private static final String WX_SECRET = "1b8bcfcb681524ac553e72054e5271ef"; |
| | | |
| | | |
| | | /** |
| | | * appID |
| | | **/ |
| | | private static final String APP_ID_PROD = "2021004150664294"; |
| | | /** |
| | | * 私钥 |
| | | */ |
| | | private static final String APP_PRIVATE_KEY = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC3ap1qQ5GTe+syB8Tu/fH8nRdpjA7yNgLINR/kFq1VFzxDref7DQDUDWXt+s5QZyBjL1UfbQWtA96F+OpgmIiNMdZSn9FH/w5XSqSd7B4nAa1sgfdLdZDvm+crqzn8OzyEJTrO8tihF+9K+btBl37s3QfmmzCRl1PAAMGqfy/JcQ2aivY+hxb25V0kD5AAXM7mVC2zzcBrykzafQCXEnDC7ls4Hjy0agmq1bKSx8SLYTsXAzZiGk9E7yh76nDAB+P1+kKPEYJXociU3k4YRR7l+6tzBPd+/mVkL34nuV5IiAK/795CrP/9gC50nZK/6CqSPDlQlOaAaJ2uZvAOeKx3AgMBAAECggEAMzw5+swjJ0KvYYtgDK6tYTZ0qswwBKLnxgto/CsFgkZ6VCGJMszgFVwkxASSi00zc+Ft8thehIUXLO9qcU9Knb51MyFnsafi1qmIMIEbryO90RjA/rg5o2U2fzFWgkn9zqAjvFmEAAQSmSwHjfwGvZ3Erjtdpt3RzEmpz7m1nJxYuZ2JLdo8AIY+iYn1NeDxHMi27RtqsZje7RV5YXrqKtMMzW2atmj+Dbn/E1pxpF0Dz6l0TqQh5B+9j1XlPTZKcYOYHNI0ACV+dV1NZsqmdhX0lKtQbsj/Q67vhq7uCmQRKcEka/5Z0X/TOKbwJE6i2/YEuA4PUGLpBMZQXhSGYQKBgQD50IuUTG6fg1dqFt9bJXxq2i1lkIHvzaCkHqVnTMyTDs+VcO2S6YaAFy6BLSI933qvHLogkhqnHiN+BRHe/M5+4TAOx30SQlJYa5ojpNFwMnRSZgxLoEddwlfj6qTnCgDW3CsUPR85x85NjIhONy75muNnNG8GHdn3blk2Y7KhpwKBgQC79TQhz5eJ6cwiWPWMWnnSAVvFKW4iPZjkbk+Sl7JXuqzvsdE47gGN0Vk8iYWEc2WrnQY6vf7WnamQYi+Gr5ySfTSt9qwvRx0IRzHdSZkOsHJLBCnAt+Pf+pSBc2Z788iUXVbDRAIfF6YYG44P3jHspbnGPJt14PP0sHbPmh7YsQKBgGzGGYChJyndjpprCyYs1FfSWCH5IhrAdkn/7hVko08FC+4OFeP6Os5bSayFcntua4UEBSdZdrF9tgaRPo7RlTg55SsKQbNJnYFSmPMcOPWZgny+YmwrheeVT5+188eF24eypi9Rzd7i2Tl7D36/GH0mrA2sDwuiw92w9rdwAb/RAoGAf6RDZPqvNI87e8/h4RDITd9yTPCXxFUEcYygKTMvf/hb3ONq7DhlgcO70CqsK4iacPLP+jBw0Zp8PnsPP24e7DRvA/zSbcDjbG285URH1vvogh0vpZq7+60WENsnq+GgQ3EnrK+QqUDMIO8FiK0iRk09XexmvqSnx3HXHaDSdeECgYB9htO5mOn2/ugIeMw11g+JJkZ/hzE55/6fLf7zh3yel5EflmAdYRv0lHafjyXIzNrAnBgD95x4LKGLi9A5AMo9SJJu0ZOg1KujKPVY4ByCm9SO7ErJDuHI4AhtewdHhYDpnXMakoxm/medSjlt7GCVv7E/eDpNZs+MLi9MiTFx2g=="; |
| | | /** |
| | | * 支付宝公钥 |
| | | */ |
| | | private static final String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlW2RMACojdqTa8H+j6411Lm5UipGXXbQiswq50rUflwjTj843zNVaVpk8uJmbdmtUBJlmblgBS/a31O4L4LrHB8WxJ+w0f9DBNTq9T6b80MiAVnU/3gXK365DmbzPWS5pR9wEgJVHnfOFUbsB5AVFHV0m9hUZcPv7xveuEp3BEoD5smaDJByR+KgFw0Q0JgINhhE6bsEa3UgJ198af269LtQ5HJl1TWLI8aeqW14HrxyADIt49NB9KZ8MOdKP+66HWcrXlipKFHtccy3dff72DqPmFdESoXfLXKZyhU5w9v4Q5F6UoAGTPwl9KQwikTobNeJ/7su7X3AB6+C14J4sQIDAQAB"; |
| | | |
| | | |
| | | @Resource |
| | | private IGoodsSeckillAppointmentService iGoodsSeckillAppointmentService; |
| | | |
| | | @Resource |
| | | private MemberClient memberClient; |
| | | |
| | | @Resource |
| | | private GoodsSeckillMapper goodsSeckillMapper; |
| | | @Resource |
| | | private GoodsSkuMapper goodsSkuMapper; |
| | | |
| | | @InnerAuth |
| | | @GetMapping("/tusonUser/{tusonUserId}") |
| | | R<?> tusonUser(@PathVariable("tusonUserId") Long tusonUserIdId){ |
| | | GoodsSeckill goodsSeckill = goodsSeckillMapper.selectById(tusonUserIdId); |
| | | LambdaQueryWrapper<GoodsSeckillAppointment> wrapper3= Wrappers.lambdaQuery(); |
| | | wrapper3.eq(GoodsSeckillAppointment::getGoodsSeckillId,tusonUserIdId); |
| | | List<GoodsSeckillAppointment> list = iGoodsSeckillAppointmentService.list(wrapper3); |
| | | for (GoodsSeckillAppointment li:list) { |
| | | Member data = memberClient.getMembeOne(li.getMemberId(), SecurityConstants.INNER).getData(); |
| | | |
| | | GoodsSku goodsSku = goodsSkuMapper.selectById(goodsSeckill.getGoodsSkuId()); |
| | | if (data.getZfbOpenid()!=null){ |
| | | try { |
| | | push1(data.getZfbOpenid(),li.getFormId(),goodsSku.getSkuName(),goodsSeckill.getSeckillPrice(),goodsSeckill.getStartTime()); |
| | | } catch (AlipayApiException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }if (data.getWxOpenid()!=null){ |
| | | push(data.getWxOpenid(),li.getFormId(),goodsSku.getSkuName(),goodsSeckill.getSeckillPrice(),goodsSeckill.getStartTime()); |
| | | } |
| | | } |
| | | |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | public String push1 (String openid, String formid, String skuName, BigDecimal seckillPrice, LocalDateTime startTime) throws AlipayApiException { |
| | | |
| | | AlipayConfig alipayConfig = new AlipayConfig(); |
| | | alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); |
| | | alipayConfig.setAppId("APP_ID_PROD"); |
| | | alipayConfig.setPrivateKey(APP_PRIVATE_KEY); |
| | | alipayConfig.setFormat("json"); |
| | | alipayConfig.setAlipayPublicKey(ALIPAY_PUBLIC_KEY); |
| | | alipayConfig.setCharset("UTF8"); |
| | | alipayConfig.setSignType("RSA2"); |
| | | AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig); |
| | | AlipayOpenAppMiniTemplatemessageSendRequest request = new AlipayOpenAppMiniTemplatemessageSendRequest(); |
| | | AlipayOpenAppMiniTemplatemessageSendModel model = new AlipayOpenAppMiniTemplatemessageSendModel(); |
| | | model.setFormId(formid); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | model.setData("{\"keyword1\": {\"value\" : \""+skuName+"\"},\"keyword2\": {\"value\" : \""+seckillPrice+"\"},\"keyword3\": {\"value\" : \""+startTime.format(formatter)+"\"}}"); |
| | | model.setPage("page/component/index"); |
| | | model.setUserTemplateId("1b6b60e0511a40b49197e83ed3d74fb2"); |
| | | model.setToUserId(openid); |
| | | request.setBizModel(model); |
| | | AlipayOpenAppMiniTemplatemessageSendResponse response = alipayClient.execute(request); |
| | | System.out.println(response.getBody()); |
| | | if (response.isSuccess()) { |
| | | System.out.println("调用成功"); |
| | | } else { |
| | | System.out.println("调用失败"); |
| | | // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接 |
| | | // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); |
| | | // System.out.println(diagnosisUrl); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String push(String openid, String formid, String skuName, BigDecimal seckillPrice, LocalDateTime startTime) { |
| | | |
| | | //1,配置小程序信息 |
| | | |
| | | WxMaInMemoryConfig wxConfig = new WxMaInMemoryConfig(); |
| | | wxConfig.setAppid("wx69e3ac6e13a889b7");//小程序appid |
| | | |
| | | wxConfig.setSecret("1b8bcfcb681524ac553e72054e5271ef");//小程序AppSecret |
| | | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | WxMaService wxMaService = new WxMaServiceImpl(); |
| | | |
| | | wxMaService.setWxMaConfig(wxConfig); |
| | | String responseAccessToken=null; |
| | | try { |
| | | responseAccessToken = getAccessTokenByWX(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | |
| | | //2,设置模版信息(keyword1:类型,keyword2:内容) |
| | | |
| | | |
| | | List<WxMaTemplateData> templateDataList = new ArrayList<>(4); |
| | | |
| | | WxMaTemplateData data1 = new WxMaTemplateData("thing1", skuName); |
| | | |
| | | WxMaTemplateData data2 = new WxMaTemplateData("amount3", seckillPrice.toString()); |
| | | |
| | | WxMaTemplateData data3 = new WxMaTemplateData("thing4", startTime.format(formatter)); |
| | | |
| | | WxMaTemplateData data4 = new WxMaTemplateData("thing5","秒杀活动开始啦,快来抢购"); |
| | | |
| | | templateDataList.add(data1); |
| | | |
| | | templateDataList.add(data2); |
| | | |
| | | templateDataList.add(data3); |
| | | |
| | | templateDataList.add(data4); |
| | | |
| | | |
| | | |
| | | //3,设置推送消息 |
| | | |
| | | WxMaTemplateMessage templateMessage = WxMaTemplateMessage.builder() |
| | | |
| | | .toUser(openid)//要推送的用户openid |
| | | |
| | | .formId(formid)//收集到的formid |
| | | |
| | | .templateId("NHmHEbK8SjzafWgnErAxNR0b2XJzSehv2kPqbQefolU")//推送的模版id(在小程序后台设置) |
| | | |
| | | .data(templateDataList)//模版信息 |
| | | |
| | | .page("pages/index/index")//要跳转到小程序那个页面 |
| | | |
| | | .build(); |
| | | |
| | | //4,发起推送 |
| | | |
| | | try { |
| | | wxMaService.getMsgService().sendTemplateMsg(templateMessage); |
| | | |
| | | } catch (WxErrorException e) { |
| | | |
| | | System.out.println("推送失败:" + e.getMessage()); |
| | | |
| | | return e.getMessage(); |
| | | |
| | | } |
| | | |
| | | return "推送成功"; |
| | | |
| | | } |
| | | |
| | | public static String getAccessTokenByWX() throws Exception { |
| | | String host = ACCESS_TOKEN_HOST + "?appid=" + WX_APPID + "&secret=" + WX_SECRET + "&grant_type=client_credential"; |
| | | Map<String, String> headers = new HashMap<>(8); |
| | | HttpResponse response = HttpUtils.doGet(host, "", "GET", headers, null); |
| | | return EntityUtils.toString(response.getEntity()); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.goods.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import java.io.Serializable; |
| | |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | |
| | | @ApiModelProperty(value = "秒杀商品id") |
| | | private Long goodsSeckillId; |
| | | |
| | |
| | | package com.ruoyi.goods.service.impl; |
| | | |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.goods.domain.GoodsSeckillAppointment; |
| | | import com.ruoyi.goods.mapper.GoodsSeckillAppointmentMapper; |
| | | import com.ruoyi.goods.service.IGoodsSeckillAppointmentService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.goods.service.IGoodsSeckillService; |
| | | import com.ruoyi.system.api.constants.DelayTaskEnum; |
| | | import com.ruoyi.system.api.domain.DelayTask; |
| | | import com.ruoyi.system.api.domain.GoodsSeckill; |
| | | import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.Duration; |
| | | import java.time.LocalDateTime; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class GoodsSeckillAppointmentServiceImpl extends ServiceImpl<GoodsSeckillAppointmentMapper, GoodsSeckillAppointment> implements IGoodsSeckillAppointmentService { |
| | | @Resource |
| | | private IGoodsSeckillService goodsSeckillService; |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private RedisService redisService; |
| | | @Override |
| | | public R goodsSeckillAppointment(HomeGoodsSkuDTO homeGoodsSkuDTO) { |
| | | GoodsSeckillAppointment goodsSeckillAppointment=new GoodsSeckillAppointment(); |
| | | goodsSeckillAppointment.setGoodsSeckillId(homeGoodsSkuDTO.getGoodsSkuId()); |
| | | goodsSeckillAppointment.setMemberId(homeGoodsSkuDTO.getMemberId()); |
| | | goodsSeckillAppointment.setFormId(homeGoodsSkuDTO.getFormId()); |
| | | this.save(goodsSeckillAppointment); |
| | | |
| | | GoodsSeckill byId = goodsSeckillService.getById(homeGoodsSkuDTO.getGoodsSkuId()); |
| | | |
| | | DelayTask delayTask = new DelayTask(); |
| | | delayTask.setDelFlag(0); |
| | | delayTask.setCreateTime(LocalDateTime.now()); |
| | | delayTask.setExecuteTime(byId.getStartTime().minusMinutes(30)); |
| | | delayTask.setRedisKey(DelayTaskEnum.AUTOMATIC_CANCEL.getCode() + "-" + byId.getId()); |
| | | sysUserClient.addDelayTask(delayTask, SecurityConstants.INNER); |
| | | |
| | | Duration duration = Duration.between(LocalDateTime.now(), byId.getStartTime().minusMinutes(30)); |
| | | |
| | | redisService.setCacheObject( |
| | | DelayTaskEnum.AUTOMATIC_CANCEL.getCode() + "-" + byId.getId(), |
| | | byId.getStartTime().minusMinutes(30), duration.getSeconds(), TimeUnit.SECONDS); |
| | | |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | wrapper4.in(GoodsSeckill::getGoodsSkuId,goodsSkuIdList); |
| | | } |
| | | |
| | | wrapper4.orderByAsc(GoodsSeckill::getSortNum); |
| | | wrapper4.orderByDesc(GoodsSeckill::getSortNum); |
| | | Page<GoodsSeckill> page2 = this.page(page, wrapper4); |
| | | |
| | | PageDTO<HomeGoodsSeckillVO> HomeGoodsSeckillVOPageDTO = PageDTO.of(page2, HomeGoodsSeckillVO.class); |
New file |
| | |
| | | package com.ruoyi.goods.utli; |
| | | |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.NameValuePair; |
| | | import org.apache.http.client.HttpClient; |
| | | import org.apache.http.client.entity.UrlEncodedFormEntity; |
| | | import org.apache.http.client.methods.HttpDelete; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.client.methods.HttpPut; |
| | | import org.apache.http.conn.ClientConnectionManager; |
| | | import org.apache.http.conn.scheme.Scheme; |
| | | import org.apache.http.conn.scheme.SchemeRegistry; |
| | | import org.apache.http.conn.ssl.SSLSocketFactory; |
| | | import org.apache.http.entity.ByteArrayEntity; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.DefaultHttpClient; |
| | | import org.apache.http.message.BasicNameValuePair; |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | import javax.net.ssl.TrustManager; |
| | | import javax.net.ssl.X509TrustManager; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.security.KeyManagementException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName HttpUtils |
| | | * @Description TODO |
| | | * @Author zhanglin |
| | | * @Date 2020/2/11 10:30 |
| | | * @Version 1.0 |
| | | **/ |
| | | public class HttpUtils { |
| | | |
| | | public static void main(String[] args) { |
| | | } |
| | | |
| | | |
| | | /** |
| | | * get |
| | | * |
| | | * @param host |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static HttpResponse doGet(String host)throws Exception { |
| | | return doGet(host, "", "GET", null, null); |
| | | } |
| | | |
| | | /** |
| | | * get |
| | | * |
| | | * @param host |
| | | * @param path |
| | | * @param method |
| | | * @param headers |
| | | * @param querys |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static HttpResponse doGet(String host, String path, String method, Map<String, String> headers, Map<String, String> querys) |
| | | throws Exception { |
| | | HttpClient httpClient = wrapClient(host); |
| | | |
| | | HttpGet request = new HttpGet(buildUrl(host, path, querys)); |
| | | if(null != headers) { |
| | | for (Map.Entry<String, String> e : headers.entrySet()) { |
| | | request.addHeader(e.getKey(), e.getValue()); |
| | | } |
| | | } |
| | | |
| | | return httpClient.execute(request); |
| | | } |
| | | |
| | | /** |
| | | * post form |
| | | * |
| | | * @param host |
| | | * @param path |
| | | * @param method |
| | | * @param headers |
| | | * @param querys |
| | | * @param bodys |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static HttpResponse doPost(String host, String path, String method, |
| | | Map<String, String> headers, |
| | | Map<String, String> querys, |
| | | Map<String, String> bodys) |
| | | throws Exception { |
| | | HttpClient httpClient = wrapClient(host); |
| | | |
| | | HttpPost request = new HttpPost(buildUrl(host, path, querys)); |
| | | |
| | | for (Map.Entry<String, String> e : headers.entrySet()) { |
| | | request.addHeader(e.getKey(), e.getValue()); |
| | | } |
| | | |
| | | if (bodys != null) { |
| | | List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>(); |
| | | |
| | | for (String key : bodys.keySet()) { |
| | | nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key))); |
| | | } |
| | | UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8"); |
| | | formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8"); |
| | | request.setEntity(formEntity); |
| | | } |
| | | |
| | | return httpClient.execute(request); |
| | | } |
| | | |
| | | /** |
| | | * Post String |
| | | * |
| | | * @param host |
| | | * @param path |
| | | * @param method |
| | | * @param headers |
| | | * @param querys |
| | | * @param body |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static HttpResponse doPost(String host, String path, String method, |
| | | Map<String, String> headers, |
| | | Map<String, String> querys, |
| | | String body) |
| | | throws Exception { |
| | | HttpClient httpClient = wrapClient(host); |
| | | |
| | | HttpPost request = new HttpPost(buildUrl(host, path, querys)); |
| | | for (Map.Entry<String, String> e : headers.entrySet()) { |
| | | request.addHeader(e.getKey(), e.getValue()); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(body)) { |
| | | request.setEntity(new StringEntity(body, "utf-8")); |
| | | } |
| | | |
| | | return httpClient.execute(request); |
| | | } |
| | | |
| | | /** |
| | | * Post stream |
| | | * |
| | | * @param host |
| | | * @param path |
| | | * @param method |
| | | * @param headers |
| | | * @param querys |
| | | * @param body |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static HttpResponse doPost(String host, String path, String method, |
| | | Map<String, String> headers, |
| | | Map<String, String> querys, |
| | | byte[] body) |
| | | throws Exception { |
| | | HttpClient httpClient = wrapClient(host); |
| | | |
| | | HttpPost request = new HttpPost(buildUrl(host, path, querys)); |
| | | for (Map.Entry<String, String> e : headers.entrySet()) { |
| | | request.addHeader(e.getKey(), e.getValue()); |
| | | } |
| | | |
| | | if (body != null) { |
| | | request.setEntity(new ByteArrayEntity(body)); |
| | | } |
| | | |
| | | return httpClient.execute(request); |
| | | } |
| | | |
| | | /** |
| | | * Put String |
| | | * @param host |
| | | * @param path |
| | | * @param method |
| | | * @param headers |
| | | * @param querys |
| | | * @param body |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static HttpResponse doPut(String host, String path, String method, |
| | | Map<String, String> headers, |
| | | Map<String, String> querys, |
| | | String body) |
| | | throws Exception { |
| | | HttpClient httpClient = wrapClient(host); |
| | | |
| | | HttpPut request = new HttpPut(buildUrl(host, path, querys)); |
| | | for (Map.Entry<String, String> e : headers.entrySet()) { |
| | | request.addHeader(e.getKey(), e.getValue()); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(body)) { |
| | | request.setEntity(new StringEntity(body, "utf-8")); |
| | | } |
| | | |
| | | return httpClient.execute(request); |
| | | } |
| | | |
| | | /** |
| | | * Put stream |
| | | * @param host |
| | | * @param path |
| | | * @param method |
| | | * @param headers |
| | | * @param querys |
| | | * @param body |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static HttpResponse doPut(String host, String path, String method, |
| | | Map<String, String> headers, |
| | | Map<String, String> querys, |
| | | byte[] body) |
| | | throws Exception { |
| | | HttpClient httpClient = wrapClient(host); |
| | | |
| | | HttpPut request = new HttpPut(buildUrl(host, path, querys)); |
| | | for (Map.Entry<String, String> e : headers.entrySet()) { |
| | | request.addHeader(e.getKey(), e.getValue()); |
| | | } |
| | | |
| | | if (body != null) { |
| | | request.setEntity(new ByteArrayEntity(body)); |
| | | } |
| | | |
| | | return httpClient.execute(request); |
| | | } |
| | | |
| | | /** |
| | | * Delete |
| | | * |
| | | * @param host |
| | | * @param path |
| | | * @param method |
| | | * @param headers |
| | | * @param querys |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static HttpResponse doDelete(String host, String path, String method, |
| | | Map<String, String> headers, |
| | | Map<String, String> querys) |
| | | throws Exception { |
| | | HttpClient httpClient = wrapClient(host); |
| | | |
| | | HttpDelete request = new HttpDelete(buildUrl(host, path, querys)); |
| | | for (Map.Entry<String, String> e : headers.entrySet()) { |
| | | request.addHeader(e.getKey(), e.getValue()); |
| | | } |
| | | |
| | | return httpClient.execute(request); |
| | | } |
| | | |
| | | private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException { |
| | | StringBuilder sbUrl = new StringBuilder(); |
| | | sbUrl.append(host); |
| | | if (!StringUtils.isBlank(path)) { |
| | | sbUrl.append(path); |
| | | } |
| | | if (null != querys) { |
| | | StringBuilder sbQuery = new StringBuilder(); |
| | | for (Map.Entry<String, String> query : querys.entrySet()) { |
| | | if (0 < sbQuery.length()) { |
| | | sbQuery.append("&"); |
| | | } |
| | | if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) { |
| | | sbQuery.append(query.getValue()); |
| | | } |
| | | if (!StringUtils.isBlank(query.getKey())) { |
| | | sbQuery.append(query.getKey()); |
| | | if (!StringUtils.isBlank(query.getValue())) { |
| | | sbQuery.append("="); |
| | | sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8")); |
| | | } |
| | | } |
| | | } |
| | | if (0 < sbQuery.length()) { |
| | | sbUrl.append("?").append(sbQuery); |
| | | } |
| | | } |
| | | |
| | | return sbUrl.toString(); |
| | | } |
| | | |
| | | private static HttpClient wrapClient(String host) { |
| | | HttpClient httpClient = new DefaultHttpClient(); |
| | | if (host.startsWith("https://")) { |
| | | sslClient(httpClient); |
| | | } |
| | | |
| | | return httpClient; |
| | | } |
| | | |
| | | private static void sslClient(HttpClient httpClient) { |
| | | try { |
| | | SSLContext ctx = SSLContext.getInstance("TLS"); |
| | | X509TrustManager tm = new X509TrustManager() { |
| | | @Override |
| | | public X509Certificate[] getAcceptedIssuers() { |
| | | return null; |
| | | } |
| | | @Override |
| | | public void checkClientTrusted(X509Certificate[] xcs, String str) { |
| | | |
| | | } |
| | | @Override |
| | | public void checkServerTrusted(X509Certificate[] xcs, String str) { |
| | | |
| | | } |
| | | }; |
| | | ctx.init(null, new TrustManager[] { tm }, null); |
| | | SSLSocketFactory ssf = new SSLSocketFactory(ctx); |
| | | ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); |
| | | ClientConnectionManager ccm = httpClient.getConnectionManager(); |
| | | SchemeRegistry registry = ccm.getSchemeRegistry(); |
| | | registry.register(new Scheme("https", 443, ssf)); |
| | | } catch (KeyManagementException ex) { |
| | | throw new RuntimeException(ex); |
| | | } catch (NoSuchAlgorithmException ex) { |
| | | throw new RuntimeException(ex); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.goods.utli; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaService; |
| | | import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; |
| | | import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; |
| | | import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; |
| | | import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.util.EntityUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class wxPush { |
| | | |
| | | |
| | | //微信 |
| | | private static final String ACCESS_TOKEN_HOST = "https://api.weixin.qq.com/cgi-bin/token"; |
| | | |
| | | private static final String WX_APPID = "wx69e3ac6e13a889b7"; |
| | | |
| | | private static final String WX_SECRET = "1b8bcfcb681524ac553e72054e5271ef"; |
| | | |
| | | public String push(String openid, String formid, String skuName, BigDecimal seckillPrice, LocalDateTime startTime) { |
| | | |
| | | //1,配置小程序信息 |
| | | |
| | | WxMaInMemoryConfig wxConfig = new WxMaInMemoryConfig(); |
| | | wxConfig.setAppid("wx69e3ac6e13a889b7");//小程序appid |
| | | |
| | | wxConfig.setSecret("1b8bcfcb681524ac553e72054e5271ef");//小程序AppSecret |
| | | |
| | | |
| | | |
| | | WxMaService wxMaService = new WxMaServiceImpl(); |
| | | |
| | | wxMaService.setWxMaConfig(wxConfig); |
| | | String responseAccessToken=null; |
| | | try { |
| | | responseAccessToken = getAccessTokenByWX(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | |
| | | //2,设置模版信息(keyword1:类型,keyword2:内容) |
| | | |
| | | |
| | | List<WxMaTemplateData> templateDataList = new ArrayList<>(4); |
| | | |
| | | WxMaTemplateData data1 = new WxMaTemplateData("thing1", skuName); |
| | | |
| | | WxMaTemplateData data2 = new WxMaTemplateData("amount3", seckillPrice.toString()); |
| | | |
| | | WxMaTemplateData data3 = new WxMaTemplateData("thing4", seckillPrice.toString()); |
| | | |
| | | WxMaTemplateData data4 = new WxMaTemplateData("thing5","秒杀活动开始啦,快来抢购"); |
| | | |
| | | templateDataList.add(data1); |
| | | |
| | | templateDataList.add(data2); |
| | | |
| | | templateDataList.add(data3); |
| | | |
| | | templateDataList.add(data4); |
| | | |
| | | |
| | | |
| | | //3,设置推送消息 |
| | | |
| | | WxMaTemplateMessage templateMessage = WxMaTemplateMessage.builder() |
| | | |
| | | .toUser(openid)//要推送的用户openid |
| | | |
| | | .formId(formid)//收集到的formid |
| | | |
| | | .templateId("NHmHEbK8SjzafWgnErAxNR0b2XJzSehv2kPqbQefolU")//推送的模版id(在小程序后台设置) |
| | | |
| | | .data(templateDataList)//模版信息 |
| | | |
| | | .page("pages/index/index")//要跳转到小程序那个页面 |
| | | |
| | | .build(); |
| | | |
| | | //4,发起推送 |
| | | |
| | | try { |
| | | wxMaService.getMsgService().sendTemplateMsg(templateMessage); |
| | | |
| | | } catch (WxErrorException e) { |
| | | |
| | | System.out.println("推送失败:" + e.getMessage()); |
| | | |
| | | return e.getMessage(); |
| | | |
| | | } |
| | | |
| | | return "推送成功"; |
| | | |
| | | } |
| | | |
| | | public static String getAccessTokenByWX() throws Exception { |
| | | String host = ACCESS_TOKEN_HOST + "?appid=" + WX_APPID + "&secret=" + WX_SECRET + "&grant_type=client_credential"; |
| | | Map<String, String> headers = new HashMap<>(8); |
| | | HttpResponse response = HttpUtils.doGet(host, "", "GET", headers, null); |
| | | return EntityUtils.toString(response.getEntity()); |
| | | } |
| | | } |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | | * 会员地址表 前端控制器 |
| | |
| | | * |
| | | */ |
| | | |
| | | @ApiModelProperty |
| | | @Resource |
| | | private IMemberAddressService iMemberAddressService; |
| | | |
| | | |
| | |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.squareup.okhttp3</groupId> |
| | | <artifactId>okhttp</artifactId> |
| | | <version>3.6.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.squareup.okio</groupId> |
| | | <artifactId>okio</artifactId> |
| | | <version>1.11.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.github.wechatpay-apiv3</groupId> |
| | | <artifactId>wechatpay-java</artifactId> |
| | | <version>0.2.12</version> |
| | |
| | | package com.ruoyi.order.controller.forepart; |
| | | |
| | | |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.order.service.IOrderService; |
| | | import com.ruoyi.system.api.domain.Order; |
| | | import com.ruoyi.system.api.domain.dto.MemberOrderDTO; |
| | | import com.ruoyi.system.api.domain.dto.MemberOrderListDTO; |
| | | import com.ruoyi.system.api.domain.vo.MemberOrderListVO; |
| | | import com.ruoyi.system.api.domain.vo.MemberOrderNumVO; |
| | | import com.ruoyi.system.api.domain.vo.MemberTiOrderVO; |
| | | import com.ruoyi.system.api.domain.vo.OrderVO; |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | |
| | | /** |
| | |
| | | public class ForepartOrderController { |
| | | |
| | | private final IOrderService orderService; |
| | | |
| | | @Resource |
| | | private GoodsSkuClient goodsSkuClient; |
| | | |
| | | @PostMapping("/saveMemberOrder") |
| | | @ApiOperation(value = "用户端-立即下单") |
| | |
| | | @PostMapping("/delOrderOne") |
| | | @ApiOperation(value = "用户端-删除订单") |
| | | public R delOrderOne(@RequestBody MemberOrderListDTO memberOrderListDTO) { |
| | | orderService.removeById(memberOrderListDTO.getId()); |
| | | orderService.delOrderOne(memberOrderListDTO); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @RequestMapping("/wxpay/notify") |
| | | public void wxnotify(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | paylogServiceImpl.notifyUrl(request,response); |
| | | paylogServiceImpl.wxnotify(request,response); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | |
| | | OrderVO MemberOrderOne(@RequestBody MemberOrderListDTO memberOrderListDTO); |
| | | void CancelOrderOne(@RequestBody MemberOrderListDTO memberOrderListDTO); |
| | | |
| | | void delOrderOne(@RequestBody MemberOrderListDTO memberOrderListDTO); |
| | | |
| | | void AffirmOrderOne(@RequestBody MemberOrderListDTO memberOrderListDTO); |
| | | |
| | | MemberOrderNumVO MemberOrderNum(@RequestBody MemberOrderListDTO memberOrderListDTO); |
| | |
| | | if (OrderDTO.getOrderFrom().getCode()==1){ |
| | | order.setOrderFrom(OrderFromEnum.COMMODITY_ORDER); |
| | | order.setOrderNo(OrderUtil.getOrderNoForPrefix("SP")); |
| | | order.setIsOrder(1); |
| | | } |
| | | if (OrderDTO.getOrderFrom().getCode()==2){ |
| | | order.setOrderFrom(OrderFromEnum.SNAP_ORDERS); |
| | | order.setOrderNo(OrderUtil.getOrderNoForPrefix("MS")); |
| | | order.setIsOrder(1); |
| | | } |
| | | if (OrderDTO.getOrderFrom().getCode()==3){ |
| | | order.setOrderFrom(OrderFromEnum.GROUP_PURCHASE_ORDERS); |
| | | order.setOrderNo(OrderUtil.getOrderNoForPrefix("TG")); |
| | | order.setIsOrder(2); |
| | | }if (OrderDTO.getOrderFrom().getCode()==4){ |
| | | order.setOrderFrom(OrderFromEnum.GROUP_PURCHASE_ORDERS); |
| | | order.setOrderNo(OrderUtil.getOrderNoForPrefix("PM")); |
| | | order.setIsOrder(1); |
| | | } |
| | | order.setOrderTime(OrderDTO.getOrderTime()); |
| | | order.setOrderFrom(OrderDTO.getOrderFrom()); |
| | |
| | | if (memberOrderDTO.getOrderFrom()==3){ |
| | | order.setOrderFrom(OrderFromEnum.GROUP_PURCHASE_ORDERS); |
| | | order.setOrderNo(OrderUtil.getOrderNoForPrefix("TG")); |
| | | order.setIsOrder(2); |
| | | } |
| | | if (memberOrderDTO.getPaymentMethod()==1){ |
| | | order.setPaymentMethod(PaymentMethodEnum.WECHAT); |
| | |
| | | if (memberOrderDTO.getOrderFrom()==3){ |
| | | order.setOrderFrom(OrderFromEnum.GROUP_PURCHASE_ORDERS); |
| | | GoodsGroupPurchase data = goodsSkuClient.getGoodsSeckiGoodsGroupPurchaseOne(memberOrderDTO.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | Integer m=data.getCurrentNumber()+1; |
| | | if (m>data.getGroupSize()){ |
| | | throw new ServiceException("对不起,大成团人数"); |
| | | } |
| | | GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(data.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | memberOrderVO.setGoodsSkuId(memberOrderDTO.getGoodsSkuId()); |
| | | memberOrderVO.setPrice(data.getGroupPurchasePrice()); |
| | |
| | | memberOrderVO.setSkuName(goodsSku.getSkuName()); |
| | | memberOrderVO.setYouhiPrice(data.getGroupPurchasePrice()); |
| | | pice=data.getGroupPurchasePrice(); |
| | | |
| | | goodsSkuClient.GroupPurchaseNum(memberOrderDTO.getGoodsSkuId(), SecurityConstants.INNER); |
| | | |
| | | order.setSkuName(goodsSku.getSkuName()); |
| | | order.setPrice(data.getGroupPurchasePrice()); |
| | |
| | | |
| | | GoodsSeckill data = goodsSkuClient.getGoodsSeckillOne(order.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(data.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | |
| | | if (order.getGoodsQuantity()!=order.getGoodsQuantity()){ |
| | | if (data.getLimitNumber()<num1){ |
| | | throw new ServiceException("对不起,大于商品购买数"); |
| | | }else{ |
| | |
| | | memberOrderVO.setCoverPic(goodsSku.getCoverPic()); |
| | | memberOrderVO.setSkuName(goodsSku.getSkuName()); |
| | | memberOrderVO.setYouhiPrice(data.getSeckillPrice()); |
| | | |
| | | } |
| | | |
| | | } if (order.getOrderFrom().getCode()==3){ |
| | | order.setOrderFrom(OrderFromEnum.GROUP_PURCHASE_ORDERS); |
| | | GoodsGroupPurchase data = goodsSkuClient.getGoodsSeckiGoodsGroupPurchaseOne(order.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | |
| | | memberOrderDTO1.setGoodsSkuId(order.getGoodsSkuId()); |
| | | Integer num=baseMapper.getGoodsGroupPurchase(memberOrderDTO1); |
| | | Integer num1=num+order.getGoodsQuantity(); |
| | | if (order.getGoodsQuantity()!=order.getGoodsQuantity()){ |
| | | if (data.getLimitNumber()<=num1){ |
| | | throw new ServiceException("对不起,大于商品购买数"); |
| | | }else{ |
| | |
| | | order.setSjPrice(goodsSku.getPrice()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | if (memberOrderDTO.getGoodsQuantity()!=null){ |
| | |
| | | if(memberOrderListDTO.getOrderStatus()!=null){ |
| | | wrapper.eq(Order::getOrderStatus,memberOrderListDTO.getOrderStatus().getCode()-1); |
| | | } |
| | | wrapper.eq(Order::getIsOrder,1); |
| | | wrapper.eq(Order::getDelFlag,0); |
| | | wrapper.orderByDesc(Order::getCancelTime); |
| | | Page<Order> page1 = this.page(page, wrapper); |
| | |
| | | memberClient.updMembeOne(MembeOneDTO, SecurityConstants.INNER); |
| | | |
| | | |
| | | if (order.getPaymentMethod() != null && order.getPaymentMethod().getCode() == 1) {//支付宝 |
| | | if (order.getPaymentMethod() != null && order.getPaymentMethod().getCode() == 2) {//支付宝 |
| | | //获取支付信息 |
| | | LambdaQueryWrapper<Paylog> paylogEntityWrapper = Wrappers.lambdaQuery(); |
| | | paylogEntityWrapper.eq(Paylog::getOutTradeNo, order.getOrderNo()); |
| | |
| | | } |
| | | } |
| | | |
| | | } else if (order.getPaymentMethod() != null && order.getPaymentMethod().getCode() == 2) {//微信 |
| | | } else if (order.getPaymentMethod() != null && order.getPaymentMethod().getCode() == 1) {//微信 |
| | | //获取支付信息 |
| | | LambdaQueryWrapper<Paylog> paylogEntityWrapper = Wrappers.lambdaQuery(); |
| | | paylogEntityWrapper.eq(Paylog::getOutTradeNo, order.getOrderNo()); |
| | |
| | | Integer refundFee = Integer.parseInt(refundMoney.substring(0, refundMoney.length() - 3)); |
| | | String money = SinataUtil.doubleRetainTwo(paylog.getPayMoney() * 100d); |
| | | Integer totalFee = Integer.parseInt(money.substring(0, money.length() - 3)); |
| | | refundFee = 1; |
| | | refundFee = Integer.parseInt(money.substring(0, money.length() - 3)); |
| | | |
| | | String regEx = "[^0-9]"; |
| | | Pattern p = Pattern.compile(regEx); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void delOrderOne(MemberOrderListDTO memberOrderListDTO) { |
| | | baseMapper.deleteById(memberOrderListDTO.getId()); |
| | | Order order = baseMapper.selectById(memberOrderListDTO.getId()); |
| | | Order byId = this.getById(memberOrderListDTO.getId()); |
| | | goodsSkuClient.GroupPurchaseNum1(byId.getGoodsSkuId(), SecurityConstants.INNER); |
| | | this.removeById(memberOrderListDTO.getId()); |
| | | if (order.getOrderStatus().getCode() == 2) { |
| | | |
| | | updMembeOneDTO MembeOneDTO = new updMembeOneDTO(); |
| | | MembeOneDTO.setType(2); |
| | | MembeOneDTO.setMemberId(order.getMemberId()); |
| | | MembeOneDTO.setMoney(order.getTotalAmount()); |
| | | MembeOneDTO.setTotalPoints(order.getPoints()); |
| | | memberClient.updMembeOne(MembeOneDTO, SecurityConstants.INNER); |
| | | |
| | | |
| | | if (order.getPaymentMethod() != null && order.getPaymentMethod().getCode() == 2) {//支付宝 |
| | | //获取支付信息 |
| | | LambdaQueryWrapper<Paylog> paylogEntityWrapper = Wrappers.lambdaQuery(); |
| | | paylogEntityWrapper.eq(Paylog::getOutTradeNo, order.getOrderNo()); |
| | | Paylog paylog = iPaylogService.getOne(paylogEntityWrapper); |
| | | if (paylog != null) { |
| | | boolean bo = paylogService.refundForAlipay(paylog.getOutTradeNo(), paylog.getTradeNo(), paylog.getPayMoney()); |
| | | if (!bo) { |
| | | System.out.println("支付宝退款失败"); |
| | | } |
| | | } |
| | | |
| | | } else if (order.getPaymentMethod() != null && order.getPaymentMethod().getCode() == 1) {//微信 |
| | | //获取支付信息 |
| | | LambdaQueryWrapper<Paylog> paylogEntityWrapper = Wrappers.lambdaQuery(); |
| | | paylogEntityWrapper.eq(Paylog::getOutTradeNo, order.getOrderNo()); |
| | | Paylog paylog = iPaylogService.getOne(paylogEntityWrapper); |
| | | if (paylog != null) { |
| | | String refundMoney = SinataUtil.doubleRetainTwo(paylog.getPayMoney() * 100d); |
| | | Integer refundFee = Integer.parseInt(refundMoney.substring(0, refundMoney.length() - 3)); |
| | | String money = SinataUtil.doubleRetainTwo(paylog.getPayMoney() * 100d); |
| | | Integer totalFee = Integer.parseInt(money.substring(0, money.length() - 3)); |
| | | refundFee = Integer.parseInt(money.substring(0, money.length() - 3)); |
| | | |
| | | String regEx = "[^0-9]"; |
| | | Pattern p = Pattern.compile(regEx); |
| | | Matcher m = p.matcher(order.getOrderNo()); |
| | | String ma = m.replaceAll("").trim(); |
| | | boolean bo = paylogService.refundForWxpay(4, paylog.getTradeNo(), paylog.getOutTradeNo(), "R" + ma, totalFee, refundFee, "2"); |
| | | if (!bo) { |
| | | System.out.println("微信退款失败"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void AffirmOrderOne(MemberOrderListDTO memberOrderListDTO) { |
| | | Order order = baseMapper.selectById(memberOrderListDTO.getId()); |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.enums.BondStatusEnum; |
| | | import com.ruoyi.common.core.enums.OrderStatusEnum; |
| | | import com.ruoyi.common.core.enums.PaymentMethodEnum; |
| | | import com.ruoyi.common.core.enums.PointStatusEnum; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.order.domain.Paylog; |
| | |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | | import com.ruoyi.system.api.feignClient.MemberClient; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | |
| | | OrderMapper.updateById(page1); |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | returnMap.put("Type",1); |
| | | return R.ok(returnMap); |
| | | } |
| | | |
| | | |
| | | page1.setOrderStatus(OrderStatusEnum.TO_BE_SHIPPED); |
| | | page1.setPayTime(LocalDateTime.now()); |
| | |
| | | MembeOneDTO.setMoney(page1.getTotalAmount()); |
| | | MembeOneDTO.setTotalPoints(page1.getPoints()); |
| | | memberClient.updMembeOne(MembeOneDTO, SecurityConstants.INNER); |
| | | |
| | | |
| | | return R.ok(returnMap); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | if (orderNO.contains("BO")) { |
| | |
| | | wrapper1.eq(OrderAuctionBond::getDelFlag,0); |
| | | OrderAuctionBond one1 = orderAuctionBondMapper.selectOne(wrapper1); |
| | | one1.setBoundStatus(BondStatusEnum.PAID); |
| | | |
| | | orderAuctionBondMapper.updateById(one1); |
| | | }else{ |
| | | LambdaQueryWrapper<Order> wrapper1= Wrappers.lambdaQuery(); |
| | | wrapper1.eq(Order::getOrderNo,paylog1.getOutTradeNo()); |
| | |
| | | System.out.println("WxpayController.notify__notityXml:\n" + notityXml); |
| | | |
| | | // 验证签名 |
| | | if (Signature.checkIsSignValidFromResponseString(1, notityXml.toString()) |
| | | || Signature.checkIsSignValidFromResponseString(2, notityXml.toString())) { |
| | | Map<String, Object> map = XMLParser.getMapFromXML(notityXml.toString()); |
| | | // log.debug("WxpayController.notify__map:\n" + map); |
| | | // 接口返回状态 |
| | |
| | | wrapper1.eq(OrderAuctionBond::getDelFlag,0); |
| | | OrderAuctionBond one1 = orderAuctionBondMapper.selectOne(wrapper1); |
| | | one1.setBoundStatus(BondStatusEnum.PAID); |
| | | one1.setPaymentMethod(PaymentMethodEnum.WECHAT); |
| | | orderAuctionBondMapper.updateById(one1); |
| | | |
| | | }else{ |
| | | LambdaQueryWrapper<Order> wrapper1= Wrappers.lambdaQuery(); |
| | |
| | | wrapper1.eq(Order::getDelFlag,0); |
| | | Order page1 = OrderMapper.selectOne(wrapper1); |
| | | page1.setOrderStatus(OrderStatusEnum.TO_BE_SHIPPED); |
| | | page1.setPaymentMethod(PaymentMethodEnum.WECHAT); |
| | | page1.setPayTime(LocalDateTime.now()); |
| | | OrderMapper.updateById(page1); |
| | | |
| | |
| | | log.debug("WxpayController.notify__回调处理:验证状态错误!" + result_code); |
| | | System.out.println("验证状态错误!" + result_code); |
| | | } |
| | | } else { |
| | | log.debug("WxpayController.notify__回调处理:通知签名验证失败!"); |
| | | System.out.println("通知签名验证失败!"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | */ |
| | | public static boolean refundForWxpay(Integer apptype, String transactionID, String outTradeNo, String outRefundNo, |
| | | Integer totalFee, Integer refundFee, String pay_type) { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | try { |
| | | // 构建接口请求参数 |
| | | com.tencent.protocol.RefundReqData refundReqData = new com.tencent.protocol.RefundReqData(transactionID, outTradeNo, outRefundNo, totalFee, refundFee, |
| | | pay_type); |
| | | |
| | | // 请求接口返回结果 |
| | | String result = requestRefundService(apptype, refundReqData); |
| | | System.out.println("微信退款返回内容:" + result); |
| | | // 获取预支付接口返回参数 |
| | | map = XMLParser.getMapFromXML(result); |
| | | System.out.println("微信退款返回参数:" + map); |
| | | // 退款成功处理 |
| | | if ("SUCCESS".equals(map.get("result_code"))) { |
| | | //生成32位随机数 |
| | | UUID uuid = UUID.randomUUID(); |
| | | String nonceStr = uuid.toString().replaceAll("-", ""); |
| | | //商品描述 String body = "XX商城-支付订单"; |
| | | // 创建hashmap(用户获得签名) |
| | | SortedMap<String, String> paraMap = new TreeMap<>(); |
| | | //设置请求参数(小程序ID) |
| | | paraMap.put("appid", Configure.getAppid()); |
| | | //设置请求参数(商户号) |
| | | paraMap.put("mch_id", Configure.getMchid()); |
| | | //设置请求参数(随机字符串) |
| | | paraMap.put("nonce_str", nonceStr); |
| | | paraMap.put("transaction_id",transactionID); |
| | | paraMap.put("out_trade_no", outTradeNo); |
| | | paraMap.put("out_refund_no", outRefundNo); |
| | | //设置请求参数(支付的总金额) |
| | | paraMap.put("total_fee", totalFee.toString()); |
| | | //设置请求参数(退款的金额) |
| | | paraMap.put("refund_fee", refundFee.toString()); |
| | | //MD5运算生成签名 |
| | | paraMap.put("sign", PaymentKit.createSign(paraMap, "HSCEWrfSYiwxR6sesZ6De91Xh3m447sh")); |
| | | System.out.println("证书: " + Configure.getCertLocalPath_2()); |
| | | |
| | | String xmlResult = WxPayApi.orderRefund(false, paraMap,Configure.getCertLocalPath_2(), Configure.getMchid()); |
| | | |
| | | return true; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | //自动取消订单 |
| | | autoCancelOrder(id); |
| | | } |
| | | else if(DelayTaskEnum.AUTOMATIC_CANCEL.getCode().equals(operation)){ |
| | | tusonUser(id); |
| | | } |
| | | //删除失效的key |
| | | redisTemplate.delete(expiredKey); |
| | | } |
| | |
| | | } |
| | | |
| | | @Async |
| | | public void tusonUser(Long tusonUserIdId) { |
| | | goodsSkuClient.tusonUser(tusonUserIdId, SecurityConstants.INNER); |
| | | } |
| | | |
| | | @Async |
| | | public void autoCancelOrder(Long orderId) { |
| | | log.info("autoCancelOrder scheduler task is running :{}", orderId); |
| | | } |