diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 90617b79..f620d1ef 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -244,7 +244,7 @@ dubbo: bxg: shop: # API_URL: http://192.168.10.113:48080/bxgApp - API_URL: https://2b36-27-19-79-216.ap.ngrok.io + API_URL: https://8d9e-27-19-79-216.jp.ngrok.io SITE_URL: http://192.168.10.113:48080/bxgApp UNI_SITE_URL: http://192.168.10.113:48080/bxgApp ADMIN_API_URL: http://192.168.10.113:48080/bxg diff --git a/zsw-bxg/pom.xml b/zsw-bxg/pom.xml index 55862492..463454cd 100644 --- a/zsw-bxg/pom.xml +++ b/zsw-bxg/pom.xml @@ -27,6 +27,11 @@ yudao-module-system-impl 1.6.2-snapshot + + com.dtflys.forest + forest-spring-boot-starter + 1.5.14 + org.springframework.boot spring-boot-configuration-processor diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/evaluation/param/YxStoreEvaluationRelationQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/evaluation/param/YxStoreEvaluationRelationQueryParam.java new file mode 100644 index 00000000..a6d9e28e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/evaluation/param/YxStoreEvaluationRelationQueryParam.java @@ -0,0 +1,26 @@ +package co.yixiang.app.modules.evaluation.param; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * 评测点赞和收藏表 查询参数对象 + *

+ * + * @author sj + * @date 2022-10-19 + */ +@Getter +@Setter +@ApiModel("查询参数对象") +public class YxStoreEvaluationRelationQueryParam { + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "商品id",required=true) + private String id; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/evaluation/rest/AppStoreEvaluationController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/evaluation/rest/AppStoreEvaluationController.java index c66f845b..94a30601 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/evaluation/rest/AppStoreEvaluationController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/evaluation/rest/AppStoreEvaluationController.java @@ -8,8 +8,17 @@ */ package co.yixiang.app.modules.evaluation.rest; +import cn.hutool.core.util.NumberUtil; +import cn.iocoder.yudao.framework.common.exception.YshopException; import cn.iocoder.yudao.framework.common.pojo.ApiResult; +import cn.iocoder.yudao.framework.security.core.annotations.AuthCheck; import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.app.common.aop.NoRepeatSubmit; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.modules.evaluation.param.YxStoreEvaluationRelationQueryParam; +import co.yixiang.app.modules.product.param.YxStoreProductRelationQueryParam; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.modules.evaluation.service.YxEvaluationRelationService; import co.yixiang.modules.evaluation.service.YxEvaluationService; import co.yixiang.utils.EntryDTO; import co.yixiang.utils.EvaluationDTO; @@ -18,9 +27,8 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -40,7 +48,7 @@ public class AppStoreEvaluationController { private final YxEvaluationService yxEvaluationService; - + private final YxEvaluationRelationService yxEvaluationRelationService; /** * 评测列表 */ @@ -61,5 +69,40 @@ public class AppStoreEvaluationController { EvaluationDTO evaluationDTO=yxEvaluationService.getEvaluationById(id); return ApiResult.ok(evaluationDTO); } + + /** + * 添加收藏 + */ + @AppLog(value = "添加收藏", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/collectEvaluation/add") + @ApiOperation(value = "添加收藏",notes = "添加收藏") + public ApiResult collectAdd(@Validated @RequestBody YxStoreEvaluationRelationQueryParam param){ + long uid = LocalUser.getUser().getUid(); + if(!NumberUtil.isNumber(param.getId())) { + throw new YshopException("参数错误哦"); + } + yxEvaluationRelationService.addEvaluationRelation(Long.valueOf(param.getId()),uid); + return ApiResult.ok(); + } + + /** + * 取消收藏 + */ + @AppLog(value = "取消收藏", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/collectEvaluation/del") + @ApiOperation(value = "取消收藏",notes = "取消收藏") + public ApiResult collectDel(@Validated @RequestBody YxStoreEvaluationRelationQueryParam param){ + long uid = LocalUser.getUser().getUid(); + if(!NumberUtil.isNumber(param.getId())) { + throw new YshopException("参数错误哦"); + } + yxEvaluationRelationService.delEvaluationRelation(Long.valueOf(param.getId()), + uid); + return ApiResult.ok(); + } } diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/rest/AppStoreOrderController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/rest/AppStoreOrderController.java index 16f2753a..ee5b0dc3 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/rest/AppStoreOrderController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/rest/AppStoreOrderController.java @@ -22,6 +22,7 @@ import co.yixiang.app.modules.services.OrderSupplyService; import cn.iocoder.yudao.framework.security.core.annotations.AuthCheck; import co.yixiang.enums.*; import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.modules.inform.service.SendMsgService; import co.yixiang.modules.mp.domain.YxWechatTemplate; import co.yixiang.modules.mp.service.WeixinPayService; import co.yixiang.modules.mp.service.YxWechatTemplateService; @@ -52,6 +53,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.io.IOException; import java.math.BigDecimal; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -82,6 +84,8 @@ public class AppStoreOrderController { private final YxStoreOrderCartInfoService storeOrderCartInfoService; private final WeixinPayService weixinPayService; + private final SendMsgService sendMsgService; + /** * 订单确认 */ @@ -135,7 +139,7 @@ public class AppStoreOrderController { @PostMapping("/order/create/{key}") @ApiOperation(value = "订单创建", notes = "订单创建") public ApiResult> create(@Valid @RequestBody OrderParam param, - @PathVariable String key) { + @PathVariable String key) throws IOException { YxUser yxUser = LocalUser.getUser(); ComputeOrderParam computeOrderParam = new ComputeOrderParam(); BeanUtil.copyProperties(param, computeOrderParam); @@ -184,7 +188,7 @@ public class AppStoreOrderController { @AuthCheck @PostMapping("/order/pay") @ApiOperation(value = "订单支付", notes = "订单支付") - public ApiResult> pay(@Valid @RequestBody PayParam param) { + public ApiResult> pay(@Valid @RequestBody PayParam param) throws IOException { Map map = new LinkedHashMap<>(); Long uid = LocalUser.getUser().getUid(); YxStoreOrderQueryVo storeOrder = storeOrderService @@ -218,6 +222,10 @@ public class AppStoreOrderController { orderSupplyService.goPay(map, orderId, uid, param.getPaytype(), param.getFrom(), orderDTO); + //这里判断是否支付成功 + if (map!=null){ + sendMsgService.inform(Long.valueOf(orderId)); + } return ApiResult.ok(map); } diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java index 3ac16830..301865fc 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java @@ -42,6 +42,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -174,14 +175,13 @@ public class OrderSupplyService { * @return map */ public Map goPay(Map map, String orderId, Long uid, String payType, - String from, OrderExtendDto orderDTO){ + String from, OrderExtendDto orderDTO) throws IOException { switch (PayTypeEnum.toType(payType)){ case WEIXIN: Map jsConfig = new HashMap<>(); if(AppFromEnum.WEIXIN_H5.getValue().equals(from)){ WxPayMwebOrderResult wxPayMwebOrderResult = (WxPayMwebOrderResult)weixinPayService .unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"H5商品购买"); - log.info("wxPayMwebOrderResult:{}",wxPayMwebOrderResult); jsConfig.put("mweb_url",wxPayMwebOrderResult.getMwebUrl()); orderDTO.setJsConfig(jsConfig); diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java index 13cc6b5f..5f2fe42a 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java @@ -17,6 +17,8 @@ import co.yixiang.app.modules.user.param.UserEditParam; import co.yixiang.logging.aop.log.AppLog; import co.yixiang.constant.ShopConstants; import co.yixiang.enums.BillInfoEnum; +import co.yixiang.modules.evaluation.service.YxEvaluationRelationService; +import co.yixiang.modules.evaluation.service.vo.YxStoreEvaluationRelationQueryVo; import co.yixiang.modules.order.service.YxStoreOrderService; import co.yixiang.modules.order.vo.UserOrderCountVo; import co.yixiang.modules.product.service.YxStoreProductRelationService; @@ -68,6 +70,7 @@ public class LetterAppUserController { private final YxSystemGroupDataService systemGroupDataService; private final YxStoreOrderService orderService; private final YxStoreProductRelationService relationService; + private final YxEvaluationRelationService evaluationRelationService; private final YxUserSignService userSignService; private final YxUserBillService userBillService; private final YxSystemConfigService systemConfigService; @@ -127,6 +130,24 @@ public class LetterAppUserController { return ApiResult.ok(relationService.userCollectProduct(page,limit,uid,type)); } + + /** + * 获取收藏评测 + */ + @AuthCheck + @GetMapping("/collectEvaluation/user") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int",dataTypeClass = Integer.class), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int",dataTypeClass = Integer.class), + @ApiImplicitParam(name = "type", value = "collect为收藏", paramType = "query", dataType = "String",dataTypeClass = String.class) + }) + @ApiOperation(value = "获取收藏的评测",notes = "获取收藏的评测") + public ApiResult> collectEvaluationUser(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit, + @RequestParam(value = "type") String type){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(evaluationRelationService.userCollectEvaluation(page,limit,uid,type)); + } /** * 用户资金统计 */ diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxStoreEvaluationRelation.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxStoreEvaluationRelation.java new file mode 100644 index 00000000..9ef8e6f6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/domain/YxStoreEvaluationRelation.java @@ -0,0 +1,40 @@ +package co.yixiang.modules.evaluation.domain; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; +import lombok.*; + + +/** + *

+ * 评测点赞和收藏表 + *

+ * + * @author sj + * @since 2022-10-19 + */ + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class YxStoreEvaluationRelation extends BaseDomain { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty(value = "用户ID") + private Long uid; + + @ApiModelProperty(value = "评测ID") + private Long evaluationId; + + @ApiModelProperty(value = "类型(收藏(collect)、点赞(like)、足迹(foot))") + private String type; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/YxEvaluationRelationService.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/YxEvaluationRelationService.java new file mode 100644 index 00000000..09a063da --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/YxEvaluationRelationService.java @@ -0,0 +1,69 @@ +package co.yixiang.modules.evaluation.service; + + +import co.yixiang.domain.PageResult; +import co.yixiang.modules.evaluation.domain.YxStoreEvaluationRelation; +import co.yixiang.modules.evaluation.service.dto.YxStoreEvaluationRelationDto; +import co.yixiang.modules.evaluation.service.vo.YxStoreEvaluationRelationQueryVo; +import co.yixiang.modules.product.service.dto.YxStoreProductRelationQueryCriteria; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + *

+ * 评测收藏表 服务类 + *

+ * + * @author hupeng + * @since 2019-10-23 + */ +public interface YxEvaluationRelationService { + /** + * 是否收藏 + * @param evaluationId 评测ID + * @param uid 用户ID + * @return Boolean + */ + Boolean isEvaluationRelation(long evaluationId, long uid); + + /** + *添加收藏 + * @param evaluationId 评测id + * @param uid 用户id + */ + void addEvaluationRelation(long evaluationId,long uid); + + /** + * 取消收藏 + * @param evaluationId 评测id + * @param uid 用户id + */ + void delEvaluationRelation(long evaluationId,long uid); + + /** + * 获取用户收藏列表 + * @param page page + * @param limit limit + * @param uid 用户id + * @return list + */ + List userCollectEvaluation(int page, int limit, Long uid, String type); + + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + PageResult queryAll(YxStoreProductRelationQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreProductRelationQueryCriteria criteria); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/dto/YxStoreEvaluationRelationDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/dto/YxStoreEvaluationRelationDto.java new file mode 100644 index 00000000..90c7318e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/dto/YxStoreEvaluationRelationDto.java @@ -0,0 +1,41 @@ +package co.yixiang.modules.evaluation.service.dto; + +import co.yixiang.modules.evaluation.domain.YxEvaluation; +import co.yixiang.modules.product.domain.YxStoreProduct; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.sql.Timestamp; + +@Data +public class YxStoreEvaluationRelationDto implements Serializable { + private Long id; + + /** 用户ID */ + private Long uid; + + private String userName; + + /** 评测ID */ + private Long evaluationId; + + private YxEvaluation evaluation; + + private YxStoreProduct product; + + /** 类型(收藏(collect)、点赞(like)) */ + private String type; + + + /** 添加时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp createTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp updateTime; + + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationRelationServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationRelationServiceImpl.java new file mode 100644 index 00000000..2ce3a58c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/impl/YxEvaluationRelationServiceImpl.java @@ -0,0 +1,131 @@ +package co.yixiang.modules.evaluation.service.impl; + + +import cn.iocoder.yudao.framework.common.exception.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.evaluation.domain.YxStoreEvaluationRelation; +import co.yixiang.modules.evaluation.service.YxEvaluationRelationService; +import co.yixiang.modules.evaluation.service.YxEvaluationService; +import co.yixiang.modules.evaluation.service.dto.YxStoreEvaluationRelationDto; +import co.yixiang.modules.evaluation.service.mapper.YxEvaluationRelationMapper; +import co.yixiang.modules.evaluation.service.vo.YxStoreEvaluationRelationQueryVo; +import co.yixiang.modules.product.service.dto.YxStoreProductRelationQueryCriteria; +import co.yixiang.modules.user.service.YxUserService; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + *

+ * 评测点赞和收藏表 服务实现类 + *

+ * + * @author sj + * @since 2022-10-19 + */ +@Slf4j +@Service +@AllArgsConstructor +@Transactional(rollbackFor = Exception.class) +public class YxEvaluationRelationServiceImpl extends BaseServiceImpl implements YxEvaluationRelationService { + + private final YxEvaluationRelationMapper yxEvaluationRelationMapper; + private final YxEvaluationService yxEvaluationService; + private final YxUserService userService; + private final IGenerator generator; + + + /** + * 是否收藏 + * @param evaluationId 评测ID + * @param uid 用户ID + * @return Boolean + */ + @Override + public Boolean isEvaluationRelation(long evaluationId, long uid) { + Long count = yxEvaluationRelationMapper + .selectCount(Wrappers.lambdaQuery() + .eq(YxStoreEvaluationRelation::getUid,uid) + .eq(YxStoreEvaluationRelation::getType,"collect") + .eq(YxStoreEvaluationRelation::getEvaluationId,evaluationId)); + if(count > 0) { + return true; + } + + return false; + } + + /** + * 添加收藏 + * @param evaluationId 评测id + * @param uid 用户id + */ + @Override + public void addEvaluationRelation(long evaluationId, long uid) { + if(isEvaluationRelation(evaluationId,uid)){ + throw new YshopException("已收藏"); + } + YxStoreEvaluationRelation storeEvaluationRelation=YxStoreEvaluationRelation.builder() + .evaluationId(evaluationId) + .uid(uid) + .build(); + yxEvaluationRelationMapper.insert(storeEvaluationRelation); + } + + /** + * 取消收藏 + * @param evaluationId 评测id + * @param uid 用户id + */ + @Override + public void delEvaluationRelation(long evaluationId, long uid) { + YxStoreEvaluationRelation evaluationRelation =this.lambdaQuery() + .eq(YxStoreEvaluationRelation::getEvaluationId,evaluationId) + .eq(YxStoreEvaluationRelation::getUid,uid) + .one(); + if (evaluationRelation == null){ + throw new YshopException("已取消"); + } + } + + /** + * 获取用户收藏列表 + * @param page page + * @param limit limit + * @param uid 用户id + * @return list + */ + @Override + public List userCollectEvaluation(int page, int limit, Long uid, String type) { + Page pageModel = new Page<>(page, limit); + List list = yxEvaluationRelationMapper.selectRelationList(pageModel,uid,type); + return list; + } + + @Override + public PageResult queryAll(YxStoreProductRelationQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + PageResult relationDtoPageResult = generator.convertPageInfo(page, YxStoreEvaluationRelationDto.class); + relationDtoPageResult.getContent().forEach(i ->{ + i.setEvaluation(yxEvaluationService.getById(i.getEvaluationId())); + i.setUserName(userService.getYxUserById(i.getUid()).getNickname()); + }); + return relationDtoPageResult; + } + + @Override + public List queryAll(YxStoreProductRelationQueryCriteria criteria) { + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreEvaluationRelation.class, criteria)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/mapper/YxEvaluationRelationMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/mapper/YxEvaluationRelationMapper.java new file mode 100644 index 00000000..aa9eefb4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/mapper/YxEvaluationRelationMapper.java @@ -0,0 +1,33 @@ +package co.yixiang.modules.evaluation.service.mapper; + + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.evaluation.domain.YxStoreEvaluationRelation; +import co.yixiang.modules.evaluation.service.vo.YxStoreEvaluationRelationQueryVo; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + *

+ * 评测点赞和收藏表 Mapper 接口 + *

+ * + * @author sj + * @since 2022-10-19 + */ +@Repository +public interface YxEvaluationRelationMapper extends CoreMapper { + + + @Select("select B.id pid,A.type as category,B.home_image as homeImage,A.id id," + + "B.is_show as isShow" + + " from yx_evaluation_relation A left join yx_evaluation B " + + "on A.evaluation_id = B.id where A.type=#{type} and A.uid=#{uid} and A.is_del = 0 and B.is_del = 0 order by A.create_time desc") + List selectRelationList(Page page, @Param("uid") Long uid, @Param("type") String type); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/vo/YxStoreEvaluationRelationQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/vo/YxStoreEvaluationRelationQueryVo.java new file mode 100644 index 00000000..0964de15 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/evaluation/service/vo/YxStoreEvaluationRelationQueryVo.java @@ -0,0 +1,34 @@ +package co.yixiang.modules.evaluation.service.vo; + +import io.swagger.annotations.ApiModelProperty; + +import java.util.Date; + +public class YxStoreEvaluationRelationQueryVo { + + private static final long serialVersionUID = 1L; + + private Long id; + + @ApiModelProperty(value = "用户ID") + private Long uid; + + @ApiModelProperty(value = "商品ID") + private Long productId; + + @ApiModelProperty(value = "类型(收藏(collect") + private String type; + + @ApiModelProperty(value = "添加时间") + private Date createTime; + + @ApiModelProperty(value = "首页图片") + private String homeImage; + + @ApiModelProperty(value = "是否显示") + private Integer isShow; + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/CardAction.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/CardAction.java new file mode 100644 index 00000000..17d1e3a1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/CardAction.java @@ -0,0 +1,12 @@ +package co.yixiang.modules.inform.domin; + +import lombok.Data; + +@Data +public class CardAction { + private Integer type; + private String url; + private String appid; + private String pagepath; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/EmphasisContent.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/EmphasisContent.java new file mode 100644 index 00000000..3bf00cd5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/EmphasisContent.java @@ -0,0 +1,11 @@ +package co.yixiang.modules.inform.domin; + +import lombok.Data; + +@Data +public class EmphasisContent { + /** 关键数据样式 "title":"100", + "desc":"数据含义"*/ + private String title; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/HorizontalContent.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/HorizontalContent.java new file mode 100644 index 00000000..897c059b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/HorizontalContent.java @@ -0,0 +1,18 @@ +package co.yixiang.modules.inform.domin; + +import lombok.Data; + + +/** 二级标题+文本列表 type:0或不填代表是普通文本,1 代表跳转url,2 代表下载附件,3 代表@员工 + keyname:二级标题、value:内容、url:链接 + * */ +@Data +public class HorizontalContent { + private String type; + private String keyname; + private String value; + private String url; + private String media_id; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/Jump.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/Jump.java new file mode 100644 index 00000000..38b58856 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/Jump.java @@ -0,0 +1,26 @@ +package co.yixiang.modules.inform.domin; + +import lombok.Data; + + +/** { + "type":1, + "url":"https://work.weixin.qq.com/?from=openApi", + "title":"企业微信官网" + }, + { + "type":2, + "appid":"APPID", + "pagepath":"PAGEPATH", + "title":"跳转小程序" + }*/ +@Data +public class Jump { + private Integer type; + private String appid; + private String url; + private String title; + private String pagepath; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/MainTitle.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/MainTitle.java new file mode 100644 index 00000000..80d89cce --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/MainTitle.java @@ -0,0 +1,11 @@ +package co.yixiang.modules.inform.domin; + +import lombok.Data; + +@Data +public class MainTitle { + /** 模版卡片的主要内容 title:一级标题、desc:标题辅助信息*/ + private String title; + private String desc; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/QuoteArea.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/QuoteArea.java new file mode 100644 index 00000000..2f06b6c9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/QuoteArea.java @@ -0,0 +1,22 @@ +package co.yixiang.modules.inform.domin; + +import lombok.Data; + + +/** 引用文献样式 + * "type":1, + "url":"https://work.weixin.qq.com/?from=openApi", + "appid":"APPID", + "pagepath":"PAGEPATH", + "title":"引用文本标题", + "quote_text":"Jack:企业微信真的很好用~\nBalian:超级好的一款软件!"*/ +@Data +public class QuoteArea { + private Integer type; + private String url; + private String appid; + private String pagepath; + private String title; + private String quote_text; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/Souce.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/Souce.java new file mode 100644 index 00000000..5930a63c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/Souce.java @@ -0,0 +1,14 @@ +package co.yixiang.modules.inform.domin; + +import io.swagger.models.auth.In; +import lombok.Data; + +@Data +public class Souce { +/**卡片来源信息模板 icon_url:来源图片url、desc:描述、desc_color:颜色 0(默认) 灰色,1 黑色,2 红色,3 绿色 */ + + private String icon_url; + private String desc; + private Integer desc_color; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/TemplateCard.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/TemplateCard.java new file mode 100644 index 00000000..67d39112 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/domin/TemplateCard.java @@ -0,0 +1,62 @@ +package co.yixiang.modules.inform.domin; + +import co.yixiang.modules.inform.domin.*; +import lombok.Data; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +@Data +@Service +public class TemplateCard { + +// /**消息类型*/ +// private String msgtype ; + /** 模板卡片的模板类型*/ + private String card_type; + + /**卡片来源信息模板 icon_url:来源图片url、desc:描述、desc_color:颜色 0(默认) 灰色,1 黑色,2 红色,3 绿色 */ + private Souce source; + + /** 模版卡片的主要内容 title:一级标题、desc:标题辅助信息*/ + private MainTitle main_title; + + /** 关键数据样式 "title":"100", + "desc":"数据含义"*/ + private EmphasisContent emphasis_content; + + /** 引用文献样式 + * "type":1, + "url":"https://work.weixin.qq.com/?from=openApi", + "appid":"APPID", + "pagepath":"PAGEPATH", + "title":"引用文本标题", + "quote_text":"Jack:企业微信真的很好用~\nBalian:超级好的一款软件!"*/ + private QuoteArea quote_area; + + + private String sub_title_text; + + /** 二级标题+文本列表 type:0或不填代表是普通文本,1 代表跳转url,2 代表下载附件,3 代表@员工 + keyname:二级标题、value:内容、url:链接 + * */ + private ArrayList horizontal_content_list; + + /** { + "type":1, + "url":"https://work.weixin.qq.com/?from=openApi", + "title":"企业微信官网" + }, + { + "type":2, + "appid":"APPID", + "pagepath":"PAGEPATH", + "title":"跳转小程序" + }*/ + private ArrayList jump_list; + + /** 0 = 未购买 1 = 已购买 "type":1, + "url":"https://work.weixin.qq.com/?from=openApi", + "appid":"APPID", + "pagepath":"PAGEPATH"*/ + private CardAction card_action; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/service/SendMsgService.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/service/SendMsgService.java new file mode 100644 index 00000000..8ab483bf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/service/SendMsgService.java @@ -0,0 +1,5 @@ +package co.yixiang.modules.inform.service; + +public interface SendMsgService { + String inform(long orderId); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/inform/service/impl/SendMsgServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/inform/service/impl/SendMsgServiceImpl.java new file mode 100644 index 00000000..c721c858 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/inform/service/impl/SendMsgServiceImpl.java @@ -0,0 +1,85 @@ +package co.yixiang.modules.inform.service.impl; + +import cn.hutool.json.JSONUtil; +import co.yixiang.modules.inform.domin.*; +import co.yixiang.modules.inform.service.SendMsgService; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.service.dto.YxStoreOrderDto; +import com.alibaba.fastjson.JSONObject; +import lombok.SneakyThrows; +import org.apache.http.HttpStatus; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +@Service +public class SendMsgServiceImpl implements SendMsgService { + + @Autowired + private YxStoreOrderService yxStoreOrderService; + + @Autowired + private TemplateCard templateCard; + + @SneakyThrows + @Override + public String inform(long orderId) { + CloseableHttpClient httpClient = HttpClients.createDefault();//实例化对象 + String webhook_url="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a2f0f8c9-e406-4f6b-86e4-d6ac9e4df88e"; + HttpPost httpPost=new HttpPost(webhook_url); + httpPost.addHeader("Content-Type", "application/json; charset=utf-8"); + + TemplateCard templateCard=this.creatTemplatecard(orderId); + Map param = new HashMap<>(); + param.put("msgtype", "template_card"); + param.put("template_card", JSONObject.parseObject(JSONUtil.toJsonStr(templateCard))); + String jsonParam = JSONObject.toJSONString(param); + + StringEntity stringEntity=new StringEntity(jsonParam, "utf-8"); + httpPost.setEntity(stringEntity); + CloseableHttpResponse response=httpClient.execute(httpPost); +// 发送成功接收返回值 + if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + String result = EntityUtils.toString(response.getEntity(), "utf-8"); + System.out.println("发送微信机器人消息成功 " + result); + return result; + } else { + System.out.println("发送微信机器人消息失败"); + } + // 关闭 + httpClient.close(); + response.close(); + return "发送微信机器人消息失败"; + } + + public TemplateCard creatTemplatecard(long orderId){ + YxStoreOrderDto yxStoreOrderDto=yxStoreOrderService.getOrderDetailByOrderId(orderId); + templateCard.setCard_type("text_notice"); + templateCard.setSource(new Souce().setDesc("眼界甄选").setIcon_url("https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0").setDesc_color(0)); + templateCard.setMain_title(new MainTitle().setTitle("有新的在线订单来啦").setDesc("订单号:"+orderId)); + templateCard.setEmphasis_content(new EmphasisContent().setTitle(yxStoreOrderDto.getPayPrice().toString()).setDesc("订单总金额")); +// templateCard.setQuote_area(new QuoteArea().setType(0).setUrl("").setAppid("APPID").setTitle("订单详情").setQuote_text("眼镜*1 0.01")); + templateCard.setSub_title_text("订单类型:"+yxStoreOrderDto.getPinkName());//订单类型 + ArrayList arrayList=new ArrayList<>(); + arrayList.add(new HorizontalContent().setKeyname("下单地址").setValue(yxStoreOrderDto.getUserAddress())); + arrayList.add(new HorizontalContent().setKeyname("下单时间").setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(yxStoreOrderDto.getCreateTime()))); + arrayList.add(new HorizontalContent().setKeyname("会员名称").setValue(yxStoreOrderDto.getRealName())); + arrayList.add(new HorizontalContent().setKeyname("会员手机号").setValue(yxStoreOrderDto.getUserPhone())); + templateCard.setHorizontal_content_list(arrayList); + ArrayList arrayList1=new ArrayList<>(); + arrayList1.add(new Jump().setType(1).setUrl("https://work.weixin.qq.com/?from=openApi").setTitle("前去处理订单")); + templateCard.setJump_list(arrayList1); + templateCard.setCard_action(new CardAction().setType(1).setUrl("https://work.weixin.qq.com/?from=openApi")); + return templateCard; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java index 965b59ea..4e242fa4 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java @@ -299,4 +299,7 @@ public interface YxStoreOrderService extends BaseService{ void retrunStock(String orderId); + + + YxStoreOrderDto getOrderDetailByOrderId(Long orderId); } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java index 9a3a55cf..878c7906 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java @@ -121,7 +121,6 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(YxStoreOrder::getOrderId, orderId); + YxStoreOrder yxStoreOrder=yxStoreOrderMapper.selectOne(wrapper); + + return this.getOrderDetail(yxStoreOrder.getId()); + }; + /** + * 获取订单详情 + * + * @param id + * @return + */ + @Override + public YxStoreOrderDto getOrderDetail(Long id) { + YxStoreOrder yxStoreOrder = this.getById(id); if (ObjectUtil.isEmpty(yxStoreOrder)) { throw new BadRequestException("订单详情不存在"); } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java index 474b32ba..38d0d854 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java @@ -49,6 +49,10 @@ public interface StoreOrderMapper extends CoreMapper { double sumPrice(@Param("uid") Long uid); +// @Select("select * from yx_store_order " + +// "where orderId=#{orderId}") +// YxStoreOrder SelectOne(@Param("orderId") Long orderId); + @Select("SELECT COUNT(*) FROM yx_store_order WHERE pay_time >= ${today}") Integer countByPayTimeGreaterThanEqual(@Param("today")int today);