Browse Source

watero感恩回馈

wangxiaoming 6 years ago
parent
commit
9a01228625

+ 3 - 12
watero-rst-web/src/main/java/com/iamberry/rst/utils/KuaiDi100.java

@@ -347,15 +347,12 @@ public class KuaiDi100 {
      * @return
      */
     public String selectCourierCompany(String code) {
-       String errorPath = "D:\\testJavaPath\\error.txt";
-       String successPath = "D:\\testJavaPath\\success.txt";
-
         String courierCompang="";
-        Map<String,Object> requestMap = new HashMap();
-        requestMap.put("LogisticCode",code);
+//        Map<String,Object> requestMap = new HashMap();
+//        requestMap.put("LogisticCode",code);
         try {
             Map<String, String> params = new HashMap<String, String>();
-            params.put("nu", "221435993148");
+            params.put("nu", code);
             String url = "http://api.open.baidu.com/pae/common/api/Redirect";
             // 发送请求
             String html = HttpClient431Util.doGet(params, url);
@@ -364,19 +361,13 @@ public class KuaiDi100 {
             String value = content.val();
             if(value == null || "".equals(value)){
                 LOGGER.info("=========快递单号:"+code+";查询不到快递公司");
-                String errorMsg = "快递单号:" + code+";查询不到快递公司+"+"\n";
-                writeTxt(errorPath,errorMsg);
             }else{
                 value = kuaidiToRstCode(value); //转换物流方式
                 LOGGER.info("=========快递单号:"+code+";查询成功,快递公司:"+code+":"+value);
-                String errorMsg = "快递单号:" + code+"快递公司:"+code+":"+value +"\n";
-                writeTxt(successPath,errorMsg);
             }
         } catch (Exception e) {
             e.printStackTrace();
             LOGGER.info("=========快递单号:"+code+";处理报错");
-            String errorMsg = "快递单号:" + code+";处理报错+"+"\n";
-            writeTxt(errorPath,errorMsg);
         }
         return courierCompang;
     }

+ 10 - 3
watero-wechat-service/src/main/java/com/iamberry/wechat/service/thanksgiving/ThanksGivingServiceImpl.java

@@ -10,6 +10,7 @@ import com.iamberry.wechat.service.mapper.ThanksGivingMapper;
 import com.iamberry.wechat.tools.StrUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Calendar;
 import java.util.Date;
@@ -62,11 +63,12 @@ public class ThanksGivingServiceImpl  implements ThanksGivingService {
      * @return Integer
      */
     @Override
+    @Transactional
     public  Integer  update(ThanksGiving  thanksGiving){
 
         CouponType couponType = couponTypeMapper.getCouponTypeById(1000);
         Calendar calendar = Calendar.getInstance();
-        calendar.add(Calendar.DATE, 90);    //增加一天
+        calendar.add(Calendar.DATE, 90);  //有效期三个月
 
         //创建优惠券
         CouponItem couponItem = new CouponItem();
@@ -78,12 +80,17 @@ public class ThanksGivingServiceImpl  implements ThanksGivingService {
         couponItem.setCouponUseStatus(1);
         couponItem.setCouponItemRemark(couponType.getCouponRemark());
         Integer flag = couponItemMapper.insertCouponItem(couponItem);
+        if(flag < 1){
+            throw new RuntimeException("创建优惠券失败");
+        }
 
-
+        thanksGiving.setCouponItemId(uuidStr);
         thanksGiving.setThanksGivingStatus(2);
         thanksGiving.setThanksGivingTime(new Date());
         flag = thanksGivingMapper.update(thanksGiving);
-
+        if(flag < 1){
+            throw new RuntimeException("修改领取状态失败");
+        }
         return  flag;
     }
 

+ 36 - 7
watero-wechat-web/src/main/java/com/iamberry/wechat/handles/thanksgiving/ThanksGivingHandler.java

@@ -7,8 +7,6 @@ import com.iamberry.wechat.core.entity.thanksgiving.ThanksGiving;
 import com.iamberry.wechat.face.member.MemberService;
 import com.iamberry.wechat.face.order.CodeService;
 import com.iamberry.wechat.face.thanksgiving.ThanksGivingService;
-import com.iamberry.wechat.service.ImberryConfig;
-import com.iamberry.wechat.tools.NameUtils;
 import com.iamberry.wechat.tools.payUtil.RandomUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -46,6 +44,28 @@ public class ThanksGivingHandler {
      * @return
      */
     @ResponseBody
+    @RequestMapping("/attention_veri")
+    public ResultMsg attentionVeri(HttpServletRequest requeste){
+        ResultMsg rm = new ResultMsg();
+        Member member =  WechatUtils.getUserBySession(requeste);
+
+        member = memberService.getMemberByUserOpenId(member.getUserOpenid());
+        if(member.getUserStatus() != 2){
+            return new ResultMsg(false, ResultMsg.ERROR, "未关注不能领取!",null);
+        }
+        rm.setMessage(ResultMsg.SUCCESS);
+        rm.setStatus(true);
+        return rm;
+    }
+
+
+    /**
+     * 发送验证码
+     * 2016年4月21日
+     * @author 穆再兴
+     * @return
+     */
+    @ResponseBody
     @RequestMapping("/send_veri")
     public ResultMsg sendPhone(HttpServletRequest request,String phone){
         ResultMsg rm = new ResultMsg();
@@ -58,9 +78,9 @@ public class ThanksGivingHandler {
         }
 //
         member = memberService.getMemberByUserOpenId(member.getUserOpenid());
-//        if(member.get){
-//
-//        }
+        if(member.getUserStatus() != 2){
+            return new ResultMsg(false, ResultMsg.ERROR, "未关注不能领取!",null);
+        }
 
         ThanksGiving thanksGiving = new ThanksGiving();
         thanksGiving.setThanksGivingPhone(phone);
@@ -97,6 +117,10 @@ public class ThanksGivingHandler {
     public ResultMsg receiveCoupon(HttpServletRequest request,String phone,String code){
         ResultMsg rm = new ResultMsg();
         Member member =  WechatUtils.getUserBySession(request);
+        member = memberService.getMemberByUserOpenId(member.getUserOpenid());
+        if(member.getUserStatus() != 2){
+            return new ResultMsg(false, ResultMsg.ERROR, "未关注不能领取!",null);
+        }
 
         if(phone.length() != 11){
             rm.setMessage(ResultMsg.ERROR);
@@ -135,8 +159,13 @@ public class ThanksGivingHandler {
         tg.setThanksGivingPhone(phone);
         tg.setThanksGivingId(thanksGivingList.get(0).getThanksGivingId());
         tg.setThanksGivingOpenId(member.getUserOpenid());
-
-        Integer flag = thanksGivingService.update(tg);
+        Integer flag = 0;
+        try{
+             thanksGivingService.update(tg);
+        }catch (Exception e){
+            e.printStackTrace();
+            return new ResultMsg(false, ResultMsg.ERROR, e.getMessage(),null);
+        }
         if(flag < 1){
             return new ResultMsg(false, ResultMsg.ERROR, "领取失败,请重新领取!",null);
         }