|
|
|
@@ -5,8 +5,10 @@ import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
|
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxAppinfo; |
|
|
|
import com.iformall.domain.po.WxCouponChannel; |
|
|
|
import com.iformall.domain.po.WxScreenAd; |
|
|
|
@@ -54,20 +56,24 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveOrUpdate(WxScreenAd record) { |
|
|
|
public ResultData saveOrUpdate(WxScreenAd record) { |
|
|
|
if (record.getId() == null) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
record.setCreateDate(new Date()); |
|
|
|
record.setUpdateDate(new Date()); |
|
|
|
setQrcode(record); |
|
|
|
if (record.getQrcode() == null) |
|
|
|
return new ResultData(ErrorCode.DEVICE_QRCODE_GET_FAILED); |
|
|
|
|
|
|
|
wxScreenAdMapper.insertSelective(record); |
|
|
|
|
|
|
|
} else { |
|
|
|
record.setUpdateDate(new Date()); |
|
|
|
setQrcode(record); |
|
|
|
wxScreenAdMapper.updateByPrimaryKeySelective(record); |
|
|
|
} |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -162,12 +168,18 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { |
|
|
|
byte[] result = null; |
|
|
|
if(responseEntity.hasBody()) { |
|
|
|
result = responseEntity.getBody(); |
|
|
|
try { |
|
|
|
JSONObject jResult = JSONObject.parseObject(result.toString()); |
|
|
|
if (jResult != null) { //error |
|
|
|
logger.error( "QRCODE get error:" + jResult.getIntValue("errcode")+"-"+ jResult.getString("errmsg")); |
|
|
|
return null; |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (result[0]==0xff){ //image |
|
|
|
return result; |
|
|
|
} else { |
|
|
|
logger.error( "QRCODE get error:" + result.toString()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
logger.error( "QRCODE get error responseEntity:" + responseEntity.toString()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |