Commit 235a6e22 by wjg

修改购物车数据格式

parent eec3144d
...@@ -3,7 +3,6 @@ package com.ihaoin.hooloo.device; ...@@ -3,7 +3,6 @@ package com.ihaoin.hooloo.device;
import android.app.Application; import android.app.Application;
import android.util.Log; import android.util.Log;
import com.ihaoin.hooloo.device.component.PushMessageReceiver;
import com.ihaoin.hooloo.device.config.AppConfig; import com.ihaoin.hooloo.device.config.AppConfig;
import com.ihaoin.hooloo.device.data.MainData; import com.ihaoin.hooloo.device.data.MainData;
import com.ihaoin.hooloo.device.network.HttpUtil; import com.ihaoin.hooloo.device.network.HttpUtil;
...@@ -27,8 +26,8 @@ public class HLApplication extends Application { ...@@ -27,8 +26,8 @@ public class HLApplication extends Application {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
UMConfigure.preInit(this, "6294708905844627b598aa78", "device_order"); UMConfigure.preInit(this, AppConfig.UMENG_APPKEY, AppConfig.UMENG_CHANNEL);
UMConfigure.init(this, "6294708905844627b598aa78", "device_order", 0, null); UMConfigure.init(this, AppConfig.UMENG_APPKEY, AppConfig.UMENG_CHANNEL, 0, null);
AppConfig.MACHINE_CODE = SharedPreferencesUtils.getMachineCode(this); AppConfig.MACHINE_CODE = SharedPreferencesUtils.getMachineCode(this);
...@@ -36,7 +35,7 @@ public class HLApplication extends Application { ...@@ -36,7 +35,7 @@ public class HLApplication extends Application {
JPushInterface.init(this); JPushInterface.init(this);
String registrationId = JPushInterface.getRegistrationID(this); String registrationId = JPushInterface.getRegistrationID(this);
Log.d(PushMessageReceiver.TAG, registrationId); Log.d(AppConfig.TAG_PUSH, registrationId);
if (!StringUtils.isEmpty(registrationId)) { if (!StringUtils.isEmpty(registrationId)) {
HttpUtil.postRegistrationId(registrationId, null); HttpUtil.postRegistrationId(registrationId, null);
} }
......
...@@ -12,7 +12,6 @@ import com.ihaoin.hooloo.device.config.AppConfig; ...@@ -12,7 +12,6 @@ import com.ihaoin.hooloo.device.config.AppConfig;
* 所有网络请求处理父类 * 所有网络请求处理父类
*/ */
public abstract class NetworkHandler extends Handler { public abstract class NetworkHandler extends Handler {
private static final String TAG = "HL_Network";
@Override @Override
public void handleMessage(@NonNull Message msg) { public void handleMessage(@NonNull Message msg) {
...@@ -20,7 +19,7 @@ public abstract class NetworkHandler extends Handler { ...@@ -20,7 +19,7 @@ public abstract class NetworkHandler extends Handler {
if (AppConfig.DEBUG) { if (AppConfig.DEBUG) {
String url = msg.getData().getString("url"); String url = msg.getData().getString("url");
String msgText = String.format("请求:%s, 返回状态:%s, 返回内容:%s", url, msg.what, msg.obj); String msgText = String.format("请求:%s, 返回状态:%s, 返回内容:%s", url, msg.what, msg.obj);
Log.d(TAG, msgText); Log.d(AppConfig.TAG_NETWORK, msgText);
} }
if (msg == null || msg.what == 0) { if (msg == null || msg.what == 0) {
return; return;
......
...@@ -8,6 +8,7 @@ import android.util.Log; ...@@ -8,6 +8,7 @@ import android.util.Log;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ihaoin.hooloo.device.config.AppConfig;
import com.ihaoin.hooloo.device.network.HttpUtil; import com.ihaoin.hooloo.device.network.HttpUtil;
import com.ihaoin.hooloo.device.util.StringUtils; import com.ihaoin.hooloo.device.util.StringUtils;
...@@ -22,7 +23,6 @@ import cn.jpush.android.api.NotificationMessage; ...@@ -22,7 +23,6 @@ import cn.jpush.android.api.NotificationMessage;
import cn.jpush.android.service.JPushMessageReceiver; import cn.jpush.android.service.JPushMessageReceiver;
public class PushMessageReceiver extends JPushMessageReceiver { public class PushMessageReceiver extends JPushMessageReceiver {
public static final String TAG = "HL_PushMessageReceiver";
private static Map<String, Handler> subscribers = new HashMap<>(); private static Map<String, Handler> subscribers = new HashMap<>();
public static void subscribe(String key, Handler handler) { public static void subscribe(String key, Handler handler) {
...@@ -35,24 +35,24 @@ public class PushMessageReceiver extends JPushMessageReceiver { ...@@ -35,24 +35,24 @@ public class PushMessageReceiver extends JPushMessageReceiver {
@Override @Override
public void onMessage(Context context, CustomMessage customMessage) { public void onMessage(Context context, CustomMessage customMessage) {
Log.e(TAG, "[onMessage] " + customMessage); Log.e(AppConfig.TAG_PUSH,"[onMessage] " + customMessage);
dispatchMsg(customMessage); dispatchMsg(customMessage);
} }
private void dispatchMsg(CustomMessage customMessage) { private void dispatchMsg(CustomMessage customMessage) {
// if (CollectionUtils.isEmpty(subscribers)) { // if (CollectionUtils.isEmpty(subscribers)) {
// Log.e(TAG, "msg subscribers is empty"); // Log.e(AppConfig.DEBUG_TAG_PUSH,"msg subscribers is empty");
// return; // return;
// } // }
JSONObject jsonObject = JSON.parseObject(customMessage.message); JSONObject jsonObject = JSON.parseObject(customMessage.message);
String action = jsonObject.getString("action"); String action = jsonObject.getString("action");
if (StringUtils.isEmpty(action)) { if (StringUtils.isEmpty(action)) {
Log.e(TAG, "msg action is empty"); Log.e(AppConfig.TAG_PUSH,"msg action is empty");
return; return;
} }
Handler handler = subscribers.get(action); Handler handler = subscribers.get(action);
if (handler == null) { if (handler == null) {
Log.e(TAG, String.format("msg action[%s] subscribers is empty", action)); Log.e(AppConfig.TAG_PUSH,String.format("msg action[%s] subscribers is empty", action));
return; return;
} }
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
...@@ -62,66 +62,54 @@ public class PushMessageReceiver extends JPushMessageReceiver { ...@@ -62,66 +62,54 @@ public class PushMessageReceiver extends JPushMessageReceiver {
@Override @Override
public void onNotifyMessageOpened(Context context, NotificationMessage message) { public void onNotifyMessageOpened(Context context, NotificationMessage message) {
Log.e(TAG, "[onNotifyMessageOpened] " + message); Log.e(AppConfig.TAG_PUSH,"[onNotifyMessageOpened] " + message);
try {
//打开自定义的Activity
// Intent i = new Intent(context, TestActivity.class);
// Bundle bundle = new Bundle();
// bundle.putString(JPushInterface.EXTRA_NOTIFICATION_TITLE,message.notificationTitle);
// bundle.putString(JPushInterface.EXTRA_ALERT,message.notificationContent);
// i.putExtras(bundle);
// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
// context.startActivity(i);
} catch (Throwable throwable) {
}
} }
@Override @Override
public void onMultiActionClicked(Context context, Intent intent) { public void onMultiActionClicked(Context context, Intent intent) {
Log.e(TAG, "[onMultiActionClicked] 用户点击了通知栏按钮"); Log.e(AppConfig.TAG_PUSH,"[onMultiActionClicked] 用户点击了通知栏按钮");
String nActionExtra = intent.getExtras().getString(JPushInterface.EXTRA_NOTIFICATION_ACTION_EXTRA); String nActionExtra = intent.getExtras().getString(JPushInterface.EXTRA_NOTIFICATION_ACTION_EXTRA);
//开发者根据不同 Action 携带的 extra 字段来分配不同的动作。 //开发者根据不同 Action 携带的 extra 字段来分配不同的动作。
if (nActionExtra == null) { if (nActionExtra == null) {
Log.d(TAG, "ACTION_NOTIFICATION_CLICK_ACTION nActionExtra is null"); Log.d(AppConfig.TAG_PUSH,"ACTION_NOTIFICATION_CLICK_ACTION nActionExtra is null");
return; return;
} }
if (nActionExtra.equals("my_extra1")) { if (nActionExtra.equals("my_extra1")) {
Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮一"); Log.e(AppConfig.TAG_PUSH,"[onMultiActionClicked] 用户点击通知栏按钮一");
} else if (nActionExtra.equals("my_extra2")) { } else if (nActionExtra.equals("my_extra2")) {
Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮二"); Log.e(AppConfig.TAG_PUSH,"[onMultiActionClicked] 用户点击通知栏按钮二");
} else if (nActionExtra.equals("my_extra3")) { } else if (nActionExtra.equals("my_extra3")) {
Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮三"); Log.e(AppConfig.TAG_PUSH,"[onMultiActionClicked] 用户点击通知栏按钮三");
} else { } else {
Log.e(TAG, "[onMultiActionClicked] 用户点击通知栏按钮未定义"); Log.e(AppConfig.TAG_PUSH,"[onMultiActionClicked] 用户点击通知栏按钮未定义");
} }
} }
@Override @Override
public void onNotifyMessageArrived(Context context, NotificationMessage message) { public void onNotifyMessageArrived(Context context, NotificationMessage message) {
Log.e(TAG, "[onNotifyMessageArrived] " + message); Log.e(AppConfig.TAG_PUSH,"[onNotifyMessageArrived] " + message);
} }
@Override @Override
public void onNotifyMessageDismiss(Context context, NotificationMessage message) { public void onNotifyMessageDismiss(Context context, NotificationMessage message) {
Log.e(TAG, "[onNotifyMessageDismiss] " + message); Log.e(AppConfig.TAG_PUSH,"[onNotifyMessageDismiss] " + message);
} }
@Override @Override
public void onRegister(Context context, String registrationId) { public void onRegister(Context context, String registrationId) {
Log.e(TAG, "[onRegister] " + registrationId); Log.e(AppConfig.TAG_PUSH,"[onRegister] " + registrationId);
HttpUtil.postRegistrationId(registrationId, null); HttpUtil.postRegistrationId(registrationId, null);
} }
@Override @Override
public void onConnected(Context context, boolean isConnected) { public void onConnected(Context context, boolean isConnected) {
Log.e(TAG, "[onConnected] " + isConnected); Log.e(AppConfig.TAG_PUSH,"[onConnected] " + isConnected);
} }
@Override @Override
public void onCommandResult(Context context, CmdMessage cmdMessage) { public void onCommandResult(Context context, CmdMessage cmdMessage) {
Log.e(TAG, "[onCommandResult] " + cmdMessage); Log.e(AppConfig.TAG_PUSH,"[onCommandResult] " + cmdMessage);
} }
@Override @Override
...@@ -151,6 +139,6 @@ public class PushMessageReceiver extends JPushMessageReceiver { ...@@ -151,6 +139,6 @@ public class PushMessageReceiver extends JPushMessageReceiver {
@Override @Override
public void onNotificationSettingsCheck(Context context, boolean isOn, int source) { public void onNotificationSettingsCheck(Context context, boolean isOn, int source) {
super.onNotificationSettingsCheck(context, isOn, source); super.onNotificationSettingsCheck(context, isOn, source);
Log.e(TAG, "[onNotificationSettingsCheck] isOn:" + isOn + ",source:" + source); Log.e(AppConfig.TAG_PUSH,"[onNotificationSettingsCheck] isOn:" + isOn + ",source:" + source);
} }
} }
...@@ -3,11 +3,18 @@ package com.ihaoin.hooloo.device.config; ...@@ -3,11 +3,18 @@ package com.ihaoin.hooloo.device.config;
public class AppConfig { public class AppConfig {
public static Boolean DEBUG = true; // TODO false public static Boolean DEBUG = true; // TODO false
public static String DEBUG_TAG = "HL_TEST"; public static String TAG = "HL_TEST";
public static String TAG_PUSH = TAG + "_PUSH";
public static String TAG_NETWORK = TAG + "_NETWORK";
/** 点单屏编码 */
public static String DEFAULT_SCREEN_NO = "A"; public static String DEFAULT_SCREEN_NO = "A";
/** 机器编码 */ /** 机器编码 */
public static String MACHINE_CODE = ""; public static String MACHINE_CODE = "";
/** 打开微信网址 */ /** 打开微信网址 */
public static String WX_URL = "http://hooloo.gdatac.com/c2?id=%s"; public static String WX_URL = "http://hooloo.gdatac.com/c2?id=%s";
public static String UMENG_APPKEY = "6294708905844627b598aa78";
public static String UMENG_CHANNEL = "DEVICE_ORDER";
} }
...@@ -5,7 +5,6 @@ import com.ihaoin.hooloo.device.data.vo.Sku; ...@@ -5,7 +5,6 @@ import com.ihaoin.hooloo.device.data.vo.Sku;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
public class ConfirmGoods implements Serializable { public class ConfirmGoods implements Serializable {
...@@ -25,10 +24,8 @@ public class ConfirmGoods implements Serializable { ...@@ -25,10 +24,8 @@ public class ConfirmGoods implements Serializable {
private String remarks; private String remarks;
/** 图片信息 */ /** 图片信息 */
private Pics pics; private Pics pics;
/** 标签 */
private List<String> tags;
/** 数量 */ /** 数量 */
private Integer count; private Integer num;
/** sku */ /** sku */
private Sku sku; private Sku sku;
...@@ -40,12 +37,12 @@ public class ConfirmGoods implements Serializable { ...@@ -40,12 +37,12 @@ public class ConfirmGoods implements Serializable {
this.goodsId = goodsId; this.goodsId = goodsId;
} }
public Integer getCount() { public Integer getNum() {
return count; return num;
} }
public void setCount(Integer count) { public void setNum(Integer num) {
this.count = count; this.num = num;
} }
public Sku getSku() { public Sku getSku() {
...@@ -103,12 +100,4 @@ public class ConfirmGoods implements Serializable { ...@@ -103,12 +100,4 @@ public class ConfirmGoods implements Serializable {
public void setPics(Pics pics) { public void setPics(Pics pics) {
this.pics = pics; this.pics = pics;
} }
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
} }
...@@ -23,8 +23,6 @@ import okhttp3.RequestBody; ...@@ -23,8 +23,6 @@ import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
public class HttpUtil { public class HttpUtil {
private static final String TAG = "HL_Network";
public static void post(String url, String body, Handler handler) { public static void post(String url, String body, Handler handler) {
if (body == null) { if (body == null) {
body = ""; body = "";
...@@ -65,7 +63,7 @@ public class HttpUtil { ...@@ -65,7 +63,7 @@ public class HttpUtil {
try { try {
if (handler == null) { if (handler == null) {
String msgText = String.format("请求:%s, 返回状态:%s, 返回内容:%s", call.request().url(), 0, e.getMessage()); String msgText = String.format("请求:%s, 返回状态:%s, 返回内容:%s", call.request().url(), 0, e.getMessage());
Log.e(TAG, msgText); Log.e(AppConfig.TAG_NETWORK, msgText);
return; return;
} }
sendHandlerMessage(0, handler, call, e); sendHandlerMessage(0, handler, call, e);
...@@ -88,7 +86,7 @@ public class HttpUtil { ...@@ -88,7 +86,7 @@ public class HttpUtil {
} }
if (handler == null) { if (handler == null) {
String msgText = String.format("请求:%s, 返回状态:%s, 返回内容:%s", call.request().url(), 1, responseBody); String msgText = String.format("请求:%s, 返回状态:%s, 返回内容:%s", call.request().url(), 1, responseBody);
Log.i(TAG, msgText); Log.i(AppConfig.TAG_NETWORK, msgText);
return; return;
} }
sendHandlerMessage(1, handler, call, jsonObject.get("data") == null ? "" : jsonObject.get("data").toString()); sendHandlerMessage(1, handler, call, jsonObject.get("data") == null ? "" : jsonObject.get("data").toString());
......
...@@ -45,6 +45,7 @@ import java.util.Date; ...@@ -45,6 +45,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
public class ConfirmOrderDialog extends Dialog { public class ConfirmOrderDialog extends Dialog {
private List<ConfirmGoods> confirmGoods = new ArrayList<>(); private List<ConfirmGoods> confirmGoods = new ArrayList<>();
...@@ -154,7 +155,7 @@ public class ConfirmOrderDialog extends Dialog { ...@@ -154,7 +155,7 @@ public class ConfirmOrderDialog extends Dialog {
confirmOrder.setSeqNo(genSeqNo()); confirmOrder.setSeqNo(genSeqNo());
confirmOrder.setGoods(confirmGoods); confirmOrder.setGoods(confirmGoods);
String json = JsonUtils.getMapper().writeValueAsString(confirmOrder); String json = JsonUtils.getMapper().writeValueAsString(confirmOrder);
Log.d(AppConfig.DEBUG_TAG, json); Log.d(AppConfig.TAG, "saveData json: " + json);
return json; return json;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -338,15 +339,12 @@ public class ConfirmOrderDialog extends Dialog { ...@@ -338,15 +339,12 @@ public class ConfirmOrderDialog extends Dialog {
return null; return null;
} }
List<ConfirmGoods> mConfirmGoods = new ArrayList<>(); return trolleyGoods.stream().map(x -> {
trolleyGoods.forEach(x -> { ConfirmGoods confirmGoods = getConfirmGoods(x.getGoods());
ConfirmGoods goods = new ConfirmGoods(); confirmGoods.setSku(x.getSku());
goods = copyGoodsAttr(x.getGoods(), goods); confirmGoods.setNum(x.getCount());
goods.setSku(x.getSku()); return confirmGoods;
goods.setCount(x.getCount()); }).collect(Collectors.toList());
mConfirmGoods.add(goods);
});
return mConfirmGoods;
} }
public List<ConfirmGoods> translate(Goods goods, Sku sku, Integer count) { public List<ConfirmGoods> translate(Goods goods, Sku sku, Integer count) {
...@@ -354,14 +352,14 @@ public class ConfirmOrderDialog extends Dialog { ...@@ -354,14 +352,14 @@ public class ConfirmOrderDialog extends Dialog {
return null; return null;
} }
ConfirmGoods confirmGoods = new ConfirmGoods(); ConfirmGoods confirmGoods = getConfirmGoods(goods);
confirmGoods = copyGoodsAttr(goods, confirmGoods);
confirmGoods.setSku(sku); confirmGoods.setSku(sku);
confirmGoods.setCount(count); confirmGoods.setNum(count);
return Arrays.asList(confirmGoods); return Arrays.asList(confirmGoods);
} }
private ConfirmGoods copyGoodsAttr(Goods goods, ConfirmGoods confirmGoods) { private ConfirmGoods getConfirmGoods(Goods goods) {
ConfirmGoods confirmGoods = new ConfirmGoods();
confirmGoods.setGoodsId(goods.getGoodsId()); confirmGoods.setGoodsId(goods.getGoodsId());
confirmGoods.setName(goods.getName()); confirmGoods.setName(goods.getName());
confirmGoods.setPrice(goods.getPrice()); confirmGoods.setPrice(goods.getPrice());
...@@ -369,7 +367,6 @@ public class ConfirmOrderDialog extends Dialog { ...@@ -369,7 +367,6 @@ public class ConfirmOrderDialog extends Dialog {
confirmGoods.setDesc(goods.getDesc()); confirmGoods.setDesc(goods.getDesc());
confirmGoods.setRemarks(goods.getRemarks()); confirmGoods.setRemarks(goods.getRemarks());
confirmGoods.setPics(goods.getPics()); confirmGoods.setPics(goods.getPics());
confirmGoods.setTags(goods.getTags());
return confirmGoods; return confirmGoods;
} }
} }
...@@ -98,8 +98,6 @@ public class GoodsDetailDialog extends Dialog { ...@@ -98,8 +98,6 @@ public class GoodsDetailDialog extends Dialog {
introViews = new ArrayList<>(); introViews = new ArrayList<>();
if (goods.getPics() != null && !CollectionUtils.isEmpty(goods.getPics().getIntroImages())) { if (goods.getPics() != null && !CollectionUtils.isEmpty(goods.getPics().getIntroImages())) {
// goods.getPics().getIntroImages().addAll(goods.getPics().getIntroImages()); // TODO TEST
for (int i = 0; i < goods.getPics().getIntroImages().size(); i++) { for (int i = 0; i < goods.getPics().getIntroImages().size(); i++) {
String url = goods.getPics().getIntroImages().get(i); String url = goods.getPics().getIntroImages().get(i);
View imgIntro = getIntroImage(url); View imgIntro = getIntroImage(url);
......
## 未解决事项 ## 未解决事项 TODO
***** *****
1. 菜单屏 订单状态变化推送对接 \ No newline at end of file
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment