qmj 3 дней назад
Родитель
Сommit
c8d204de43

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/app/order/PosOrderController.java

@@ -1760,7 +1760,7 @@ public class PosOrderController extends BaseController {
     @RequestMapping(value = "/testPushMessage", method = {RequestMethod.GET})
     public AjaxResult testPushMessage(String cid, String title, String content, String body) {
         PayPush push = new PayPush();
-        push.qspush(cid, title, content, body);
+        push.apppush(cid, title, content, body);
         return AjaxResult.success();
     }
 

+ 65 - 70
ruoyi-admin/src/main/java/com/ruoyi/app/order/PosReviewController.java

@@ -5,6 +5,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
+import cn.hutool.core.util.StrUtil;
 import com.ruoyi.system.domain.*;
 import jakarta.servlet.http.HttpServletResponse;
 
@@ -41,8 +42,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
  */
 @RestController
 @RequestMapping("/system/review")
-public class PosReviewController extends BaseController
-{
+public class PosReviewController extends BaseController {
     @Autowired
     private IPosReviewService posReviewService;
     @Autowired
@@ -55,10 +55,11 @@ public class PosReviewController extends BaseController
     @Autowired
     private IUserWalletService userWalletService;
     @Autowired
-    private IPointsTransactionService  pointsTransactionService;
+    private IPointsTransactionService pointsTransactionService;
 
     /**
      * 查询用户的评论列表
+     *
      * @param token
      * @param page
      * @param size
@@ -69,28 +70,30 @@ public class PosReviewController extends BaseController
     @GetMapping("/getUserRevew")
     public AjaxResult getUserRevew(
             @RequestHeader String token,
+            @RequestParam String ddId,
             @RequestParam Integer page,
-                                 @RequestParam Integer size
-                              ){
+            @RequestParam Integer size
+    ) {
         JwtUtil jwtUtil = new JwtUtil();
         String id = jwtUtil.getusid(token);
-        Long userId=Long.valueOf(id);
-        IPage<PosReview> palist = new Page<>(page,size);
-        QueryWrapper<PosReview> Wrapper= new QueryWrapper<>();
-        Wrapper.eq("user_id",userId);
-        IPage<PosReview> list =  posReviewService.page(palist,Wrapper);
+        Long userId = Long.valueOf(id);
+        IPage<PosReview> palist = new Page<>(page, size);
+        QueryWrapper<PosReview> Wrapper = new QueryWrapper<>();
+        Wrapper.eq("user_id", userId);
+        Wrapper.eq(!StrUtil.isEmpty(ddId),"dd_id",ddId);
+        IPage<PosReview> list = posReviewService.page(palist, Wrapper);
         List<PosReview> orlist = list.getRecords();
         JSONArray arr = new JSONArray();
-        for(int i=0;i<orlist.size();i++){
+        for (int i = 0; i < orlist.size(); i++) {
             JSONObject org = new JSONObject();
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            org.put("id",orlist.get(i).getId());
-            org.put("ddId",orlist.get(i).getDdId());
-            org.put("score",orlist.get(i).getScore());
-            org.put("cretim",sdf.format(orlist.get(i).getCretim()));
-            org.put("content",orlist.get(i).getContent());
-            org.put("images",orlist.get(i).getImages());
-            org.put("user",orlist.get(i).getAnonymous()==0?infoUserService.getById(orlist.get(i).getUserId()):"匿名");
+            org.put("id", orlist.get(i).getId());
+            org.put("ddId", orlist.get(i).getDdId());
+            org.put("score", orlist.get(i).getScore());
+            org.put("cretim", sdf.format(orlist.get(i).getCretim()));
+            org.put("content", orlist.get(i).getContent());
+            org.put("images", orlist.get(i).getImages());
+            org.put("user", orlist.get(i).getAnonymous() == 0 ? infoUserService.getById(orlist.get(i).getUserId()) : "匿名");
             arr.add(org);
         }
         return success(arr);
@@ -100,23 +103,23 @@ public class PosReviewController extends BaseController
     @GetMapping("/getmdrevew")
     public AjaxResult getmdrevew(@RequestParam Integer page,
                                  @RequestParam Integer size,
-                                 @RequestParam Long mdid){
-        IPage<PosReview> palist = new Page<>(page,size);
-        QueryWrapper<PosReview> Wrapper= new QueryWrapper<>();
-        Wrapper.eq("md_id",mdid);
-        IPage<PosReview> list =  posReviewService.page(palist,Wrapper);
+                                 @RequestParam Long mdid) {
+        IPage<PosReview> palist = new Page<>(page, size);
+        QueryWrapper<PosReview> Wrapper = new QueryWrapper<>();
+        Wrapper.eq("md_id", mdid);
+        IPage<PosReview> list = posReviewService.page(palist, Wrapper);
         List<PosReview> orlist = list.getRecords();
         JSONArray arr = new JSONArray();
-        for(int i=0;i<orlist.size();i++){
+        for (int i = 0; i < orlist.size(); i++) {
             JSONObject org = new JSONObject();
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            org.put("id",orlist.get(i).getId());
-            org.put("ddId",orlist.get(i).getDdId());
-            org.put("score",orlist.get(i).getScore());
-            org.put("cretim",sdf.format(orlist.get(i).getCretim()));
-            org.put("content",orlist.get(i).getContent());
-            org.put("images",orlist.get(i).getImages());
-            org.put("user",orlist.get(i).getAnonymous()==0?infoUserService.getById(orlist.get(i).getUserId()):"匿名");
+            org.put("id", orlist.get(i).getId());
+            org.put("ddId", orlist.get(i).getDdId());
+            org.put("score", orlist.get(i).getScore());
+            org.put("cretim", sdf.format(orlist.get(i).getCretim()));
+            org.put("content", orlist.get(i).getContent());
+            org.put("images", orlist.get(i).getImages());
+            org.put("user", orlist.get(i).getAnonymous() == 0 ? infoUserService.getById(orlist.get(i).getUserId()) : "匿名");
             arr.add(org);
         }
         return success(arr);
@@ -126,59 +129,60 @@ public class PosReviewController extends BaseController
     @Anonymous
     @Auth
     @PostMapping("/addrevew")
-    public AjaxResult addrevew(@RequestHeader String token,@RequestBody PosReview posReview)
-    {
+    public AjaxResult addrevew(@RequestHeader String token, @RequestBody PosReview posReview) {
         JwtUtil jwtUtil = new JwtUtil();
         String id = jwtUtil.getusid(token);
         PosReview review = posReviewMapper.getrewiew(posReview.getDdId());
-        if(review==null){
+        if (review == null) {
             posReview.setUserId(Long.valueOf(id));
             //判断是否为新增
-            if(ObjectUtil.isEmpty(posReview.getId())){
-                addPoint(Long.valueOf(id),posReview.getDdId());
+            if (ObjectUtil.isEmpty(posReview.getId())) {
+                addPoint(Long.valueOf(id), posReview.getDdId());
             }
             boolean org = posReviewService.saveOrUpdate(posReview);
-            if(org){
+            if (org) {
                 return success(MessageUtils.message("no.comment.success"));
-            }else {
+            } else {
                 throw new ServiceException(MessageUtils.message("no.comment.fail"));
             }
-        }else {
+        } else {
             return error(MessageUtils.message("no.comment.repeat"));
         }
     }
+
     /**
      * 添加积分
      */
-    private void addPoint(Long userid, String ddId){
+    private void addPoint(Long userid, String ddId) {
         SysPointControl control = pointControlService.getById(1);
         //开启评论获得积分
-        if(control.getReviewEnable().equals(1L)){
-            LambdaQueryWrapper<UserWallet> walletQuery=new LambdaQueryWrapper<>();
-            walletQuery.eq(UserWallet::getUserId,userid);
+        if (control.getReviewEnable().equals(1L)) {
+            LambdaQueryWrapper<UserWallet> walletQuery = new LambdaQueryWrapper<>();
+            walletQuery.eq(UserWallet::getUserId, userid);
             UserWallet userWallet = userWalletService.getOne(walletQuery);
 
-            if(userWallet==null){
+            if (userWallet == null) {
 
                 userWalletService.createUserWallet(userid);
-            }else{
+            } else {
                 Long userPoint = userWallet.getPointsWallet();
                 Long point = control.getReviewPoints();
-                long newPoint = userPoint+point;
+                long newPoint = userPoint + point;
                 userWallet.setPointsWallet(newPoint);
                 int oldVersion = userWallet.getVersion();
-                userWallet.setVersion(userWallet.getVersion()+1);
-                walletQuery.eq(UserWallet::getVersion,oldVersion);
-               boolean update= userWalletService.update(userWallet,walletQuery);
-               if(!update){
-                   throw new ServiceException(MessageUtils.message("no.points.update.fail"));
-               }
-                createPointTransaction(userid,control.getReviewPoints(), userWallet.getPointsWallet(), ddId,"1");
+                userWallet.setVersion(userWallet.getVersion() + 1);
+                walletQuery.eq(UserWallet::getVersion, oldVersion);
+                boolean update = userWalletService.update(userWallet, walletQuery);
+                if (!update) {
+                    throw new ServiceException(MessageUtils.message("no.points.update.fail"));
+                }
+                createPointTransaction(userid, control.getReviewPoints(), userWallet.getPointsWallet(), ddId, "1");
             }
 
         }
 
     }
+
     /**
      * 创建积分流水
      */
@@ -192,8 +196,7 @@ public class PosReviewController extends BaseController
 //        pointsTransaction.setCreateTime(new Date());
 //        pointsTransactionService.save(pointsTransaction);
 //    }
-
-    private void createPointTransaction(Long userid, Long pointsChange, Long currentPoints, String ddId,String type) {
+    private void createPointTransaction(Long userid, Long pointsChange, Long currentPoints, String ddId, String type) {
         PointsTransaction pointsTransaction = new PointsTransaction();
         pointsTransaction.setUserId(userid);
         if (type.equals("1")) {
@@ -211,15 +214,12 @@ public class PosReviewController extends BaseController
     }
 
 
-
-
     /**
      * 查询review列表
      */
     @PreAuthorize("@ss.hasPermi('system:review:list')")
     @GetMapping("/list")
-    public TableDataInfo list(PosReview posReview)
-    {
+    public TableDataInfo list(PosReview posReview) {
         startPage();
         List<PosReview> list = posReviewService.selectPosReviewList(posReview);
         return getDataTable(list);
@@ -231,8 +231,7 @@ public class PosReviewController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:review:export')")
     @Log(title = "review", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, PosReview posReview)
-    {
+    public void export(HttpServletResponse response, PosReview posReview) {
         List<PosReview> list = posReviewService.selectPosReviewList(posReview);
         ExcelUtil<PosReview> util = new ExcelUtil<PosReview>(PosReview.class);
         util.exportExcel(response, list, MessageUtils.message("no.export.excel.review"));
@@ -243,8 +242,7 @@ public class PosReviewController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:review:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(posReviewService.selectPosReviewById(id));
     }
 
@@ -254,8 +252,7 @@ public class PosReviewController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:review:add')")
     @Log(title = "review", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody PosReview posReview)
-    {
+    public AjaxResult add(@RequestBody PosReview posReview) {
         return toAjax(posReviewService.insertPosReview(posReview));
     }
 
@@ -265,8 +262,7 @@ public class PosReviewController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:review:edit')")
     @Log(title = "review", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody PosReview posReview)
-    {
+    public AjaxResult edit(@RequestBody PosReview posReview) {
         return toAjax(posReviewService.updatePosReview(posReview));
     }
 
@@ -275,9 +271,8 @@ public class PosReviewController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:review:remove')")
     @Log(title = "review", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(posReviewService.deletePosReviewByIds(ids));
     }
 }

+ 7 - 6
ruoyi-admin/src/main/java/com/ruoyi/app/utils/PayPush.java

@@ -1,6 +1,7 @@
 package com.ruoyi.app.utils;
 
 import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 
@@ -13,8 +14,8 @@ public class PayPush {
         String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msduser?cid="+cid+
                 "&title="+title+"&content="+content+"&payload="+body;
         String res="";
-//        res = HttpUtil.get(url);
-        //JSONObject jsonObject =  JSON.parseObject(res);
+        res = HttpUtil.get(url);
+        JSONObject jsonObject =  JSON.parseObject(res);
         System.out.println("=========================1111111111111111"+res);
     }
 
@@ -44,8 +45,8 @@ public class PayPush {
         String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msdrider?cid="+cid+
                 "&title="+title+"&content="+content+"&payload="+body+"&sound=pushsound.caf";
         String res="";
-//        res = HttpUtil.get(url);
-        //JSONObject jsonObject =  JSON.parseObject(res);
+        res = HttpUtil.get(url);
+        JSONObject jsonObject =  JSON.parseObject(res);
         System.out.println("=========================用户推送"+res);
     }
     //商家端推送
@@ -54,8 +55,8 @@ public class PayPush {
         String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msdstore?cid="+cid+
                 "&title="+title+"&content="+content+"&payload="+body;
         String res="";
-//        res = HttpUtil.get(url);
-        //JSONObject jsonObject =  JSON.parseObject(res);
+        res = HttpUtil.get(url);
+        JSONObject jsonObject =  JSON.parseObject(res);
         System.out.println("=========================商家推送"+res);
     }
 }