/** 获取订单对应的维权列表 */ public void acc() { Map<String, Object> resultMap = new HashMap<String, Object>(); String userid = this.getPara("uid"); String orderId = this.getPara("orderid"); if (StringUtil.isNull(userid) || StringUtil.isNull(orderId)) { formatInvalidParamResponse(resultMap); } else { AbOrder order = AbOrder.dao.findById(orderId); if (order == null) { AbTcExpressOrder tc = AbTcExpressOrder.dao.findById(orderId); if (tc != null) { order = AbOrder.dao.findFirst("select * from ab_order where sn = ?", tc.getStr("sn")); if (order != null) { orderId = order.getStr("id"); } } } Record r = Db.findFirst( "SELECT aocb.*,tu.mc FROM ab_order_chargeback AS aocb,sys_user AS tu WHERE aocb.apply_id = tu.id AND aocb.order_id=?", new Object[] {orderId}); resultMap.put("result", RESULT_SUCCESS); resultMap.put("msg", "查询成功"); resultMap.put("data", r); } renderJson(resultMap); }
/** 申请退单 */ public void addchargeback() { SysUser abuser = this.getSessionAttr("abuser"); if (abuser == null || abuser.get("id") == null) { redirect("/ab/login"); } else { String inputRandomCode = this.getPara("backCaptchaCode"); String orderId = this.getPara("orderid"); String content = this.getPara("applyBackContent"); String img_url = this.getPara("apyimg"); Object objMd5RandomCode = this.getSessionAttr(CaptchaRender.DEFAULT_CAPTCHA_MD5_CODE_KEY); // 验证验证码 if (!CaptchaRender.validate(objMd5RandomCode.toString(), inputRandomCode)) { this.renderJson("1"); } // 验证content else if (StringUtil.isNull(content) || content.length() > 100) { this.renderJson("2"); } // 判断是否已经申请退单 else if (AbOrderChargeback.dao.findFirst( "select * from ab_order_chargeback where order_id = '" + orderId + "'") != null) { this.renderJson("3"); } // 插入退单记录 else { abuser = SysUser.dao.findById(abuser.get("id")); AbOrder order = AbOrder.dao.findById(orderId); AbOrderChargeback cb = new AbOrderChargeback(); cb.set(AbOrderChargeback.ID, StringUtil.getUuid32()); cb.set(AbOrderChargeback.MER_ID, order.getStr(AbOrder.MID)); cb.set(AbOrderChargeback.XDR_ID, order.getStr(AbOrder.XDRID)); cb.set(AbOrderChargeback.QDR_ID, order.getStr(AbOrder.QDRID)); cb.set(AbOrderChargeback.ORDER_ID, orderId); cb.set(AbOrderChargeback.APPLY_ID, abuser.get(SysUser.ID)); cb.set(AbOrderChargeback.APPLY_DESC, content); cb.set(AbOrderChargeback.APPLY_TIME, DateUtil.getCurrentDate()); cb.set(AbOrderChargeback.STATUS, CommonStaticData.CB_STATUS1); // 申请人类型 1 用户 2商户 3业务员 if (CommonStaticData.USER_TYPE_MEMBER.equals(abuser.get(SysUser.ROLE_ID))) { cb.set(AbOrderChargeback.CB_STATUS, CommonStaticData.CB_TYPE1); cb.set(AbOrderChargeback.APPLY_TYPE, CommonStaticData.CB_APPLYTYPE_MEMBER); } else if (CommonStaticData.USER_TYPE_MERCHANT.equals(abuser.get(SysUser.ROLE_ID))) { cb.set(AbOrderChargeback.CB_STATUS, CommonStaticData.CB_TYPE2); cb.set(AbOrderChargeback.APPLY_TYPE, CommonStaticData.CB_APPLYTYPE_MERCHANT); } else if (CommonStaticData.USER_TYPE_SERVICE.equals(abuser.get(SysUser.ROLE_ID))) { cb.set(AbOrderChargeback.CB_STATUS, CommonStaticData.CB_TYPE8); cb.set(AbOrderChargeback.APPLY_TYPE, CommonStaticData.CB_APPLYTYPE_SERVICE); } if (!StringUtil.isNull(img_url)) { FileInputStream file = null; try { file = new FileInputStream(PathKit.getWebRootPath() + "\\upload\\" + img_url); } catch (FileNotFoundException e) { e.printStackTrace(); } cb.set(AbOrderChargeback.APPLY_IMG_URL, img_url); cb.set(AbOrderChargeback.APPLY_IMG, file); } cb.save(); String sn = order.getStr("sn"); String userid = abuser.getStr("id"); String roleid = abuser.getStr("role_id"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String str_date = df.format(new Date()); Record record = new Record(); record.set("id", StringUtil.getUuid32()); record.set("user_id", userid); record.set("role_id", roleid); record.set("mes_title", "退单消息"); record.set("mes_type", "0"); record.set("isread", "0"); record.set("text", "申请退单成功!订单号:" + sn); record.set("send_date", str_date); Db.save("message", record); this.renderJson("0"); } } }
/** * 用户申请退单 参数 userid 用户ID orderid 订单ID content 描述 apyimg 图片路径 * * <p>返回值 true or false */ public void addchargeback() { Map<String, Object> resultMap = new HashMap<String, Object>(); String userid = this.getPara("uid"); String orderId = this.getPara("orderid"); String content = this.getPara("content"); String img_url = this.getPara("apyimg"); if (StringUtil.isNull(userid) || StringUtil.isNull(orderId) || StringUtil.isNull(content)) { formatInvalidParamResponse(resultMap); } else { // 插入退单记录 SysUser abuser = SysUser.dao.findById(userid); AbOrder order = AbOrder.dao.findFirst("SELECT * FROM ab_order WHERE sn='" + orderId + "' "); if (order == null) { order = AbOrder.dao.findFirst("SELECT * FROM ab_order WHERE id='" + orderId + "' "); } if (null == abuser || null == order) { resultMap.put("result", RESULT_FAIL); resultMap.put("msg", "数据异常,请稍后重试!"); } else { AbOrderChargeback cb = null; cb = AbOrderChargeback.dao.findFirst( "select * from ab_order_chargeback where order_id = '" + orderId + "'"); boolean flag = false; if (cb == null) { cb = new AbOrderChargeback(); cb.set(AbOrderChargeback.ID, StringUtil.getUuid32()); flag = true; } cb.set(AbOrderChargeback.ID, StringUtil.getUuid32()); cb.set(AbOrderChargeback.MER_ID, order.getStr(AbOrder.MID)); cb.set(AbOrderChargeback.XDR_ID, order.getStr(AbOrder.XDRID)); cb.set(AbOrderChargeback.QDR_ID, order.getStr(AbOrder.QDRID)); cb.set(AbOrderChargeback.ORDER_ID, orderId); cb.set(AbOrderChargeback.APPLY_ID, abuser.get(SysUser.ID)); cb.set(AbOrderChargeback.APPLY_DESC, content); cb.set(AbOrderChargeback.APPLY_TIME, DateUtil.getCurrentDate()); cb.set(AbOrderChargeback.STATUS, CommonStaticData.CB_STATUS1); // 申请人类型 1 用户 2商户 3业务员 if (CommonStaticData.USER_TYPE_MEMBER.equals(abuser.get(SysUser.ROLE_ID))) { cb.set(AbOrderChargeback.CB_STATUS, CommonStaticData.CB_TYPE1); cb.set(AbOrderChargeback.APPLY_TYPE, CommonStaticData.CB_APPLYTYPE_MEMBER); } else if (CommonStaticData.USER_TYPE_MERCHANT.equals(abuser.get(SysUser.ROLE_ID))) { cb.set(AbOrderChargeback.CB_STATUS, CommonStaticData.CB_TYPE2); cb.set(AbOrderChargeback.APPLY_TYPE, CommonStaticData.CB_APPLYTYPE_MERCHANT); } else if (CommonStaticData.USER_TYPE_SERVICE.equals(abuser.get(SysUser.ROLE_ID))) { cb.set(AbOrderChargeback.CB_STATUS, CommonStaticData.CB_TYPE8); cb.set(AbOrderChargeback.APPLY_TYPE, CommonStaticData.CB_APPLYTYPE_SERVICE); } if (!StringUtil.isNull(img_url)) { FileInputStream file = null; try { file = new FileInputStream(PathKit.getWebRootPath() + "\\upload\\" + img_url); } catch (FileNotFoundException e) { e.printStackTrace(); } cb.set(AbOrderChargeback.APPLY_IMG_URL, img_url); cb.set(AbOrderChargeback.APPLY_IMG, file); } if (flag) { cb.update(); } else { cb.save(); } resultMap.put("result", RESULT_SUCCESS); resultMap.put("msg", "维权成功,请耐心等待调解结果"); } } renderJson(resultMap); }
/*商户回复 1同意退单,2申诉*/ public void addcbReponse() { SysUser abuser = this.getSessionAttr("abuser"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String str_date = df.format(new Date()); if (abuser == null || abuser.get("id") == null) { redirect("/ab/login"); } else { String cbid = this.getPara("cbid"); String agree = this.getPara("agree"); String inputRandomCode = this.getPara("captchaCode"); String content = this.getPara("content"); Object objMd5RandomCode = this.getSessionAttr(CaptchaRender.DEFAULT_CAPTCHA_MD5_CODE_KEY); // 验证验证码 if (!CaptchaRender.validate(objMd5RandomCode.toString(), inputRandomCode)) { this.renderJson("1"); } // 验证content else if (StringUtil.isNull(content) || content.length() > 100) { this.renderJson("2"); } // 更新退单记录 else { AbOrderChargeback cb = AbOrderChargeback.dao.findById(cbid); cb.set(AbOrderChargeback.REP_DESC, content); cb.set(AbOrderChargeback.REP_TIME, DateUtil.getCurrentDate()); SysUser mer = SysUser.dao.findById(abuser.getStr(SysUser.ID)); SysUser user = SysUser.dao.findById(cb.getStr(AbOrderChargeback.XDR_ID)); // 同意 if (agree.equals("1")) { // 更新退单状态 cb.set(AbOrderChargeback.CB_STATUS, CommonStaticData.CB_TYPE6); cb.set(AbOrderChargeback.STATUS, CommonStaticData.CB_STATUS3); // 金额 AbOrder order = AbOrder.dao.findById(cb.getStr(AbOrderChargeback.ORDER_ID)); BigDecimal money = order.getBigDecimal(AbOrder.DDZJE); // 更新订单状态 order.set(AbOrder.DDZT, "5"); order.update(); // 商户余额金额减少 BigDecimal merye = mer.getBigDecimal(SysUser.ZHYE); mer.set(SysUser.ZHYE, merye.subtract(money)); mer.update(); // 用户余额增加 BigDecimal userye = mer.getBigDecimal(SysUser.ZHYE); user.set(SysUser.ZHYE, userye.add(money)); // 判断是否已经支付,如果已经支付,则扣除积分 if ("1".equals(order.getStr(AbOrder.ZFZT))) { int jf = user.getInt(SysUser.JIFEN); int mjf = money.setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); user.set(SysUser.JIFEN, jf - mjf); } user.update(); String sn = order.getStr("sn"); String userid = user.getStr("id"); String roleid = user.getStr("role_id"); Record record = new Record(); record.set("id", StringUtil.getUuid32()); record.set("user_id", userid); record.set("role_id", roleid); record.set("mes_title", "退单消息"); record.set("mes_type", "0"); record.set("isread", "0"); record.set("text", "商户同意退单!订单号:" + sn); record.set("send_date", str_date); Db.save("message", record); } else { cb.set(AbOrderChargeback.CB_STATUS, CommonStaticData.CB_TYPE3); String userid = user.getStr("id"); String roleid = user.getStr("role_id"); Record record = new Record(); record.set("id", StringUtil.getUuid32()); record.set("user_id", userid); record.set("role_id", roleid); record.set("mes_title", "退单消息"); record.set("mes_type", "0"); record.set("isread", "0"); record.set("text", "商户已提起申诉!"); record.set("send_date", str_date); Db.save("message", record); } cb.update(); this.renderJson("0"); } } }