仙人 登録日: 2007/11/23 居住地: 投稿: 308 |
Re: ポイント付与のタイミングについて 本番環境にて問題なく動作しました。しかし、初歩的なミスをしていました。お客様が注文後、ステータスを発送済みにする前に同じお客様が追加の注文があった場合、1回目のポイントが加算されないことがわかり訂正しました。また、発送済みにした時だけポイント付与されるようにしました。 LC_Page_Shopping_Complete.phpを変更。 引用: /* 購入情報を会員テーブルに登録する */ function lfSetCustomerPurchase($customer_id, $arrData, &$objQuery) { $col = "first_buy_date, last_buy_date, buy_times, buy_total, point"; $where = "customer_id = ?"; $arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id)); $sqlval = $arrRet[0];
if($sqlval['first_buy_date'] == "") { $sqlval['first_buy_date'] = "Now()"; } $sqlval['last_buy_date'] = "Now()"; $sqlval['buy_times']++; $sqlval['buy_total']+= $arrData['total']; $sqlval['point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']);
// ポイントが不足している場合 if($sqlval['point'] < 0) { $objQuery->rollback(); SC_Utils_Ex::sfDispSiteError(LACK_POINT); }
$objQuery->update("dtb_customer", $sqlval, $where, array($customer_id)); }
上記を下記に変更。 引用: /* 購入情報を会員テーブルに登録する */ function lfSetCustomerPurchase($customer_id, $arrData, &$objQuery) { $col = "first_buy_date, last_buy_date, buy_times, buy_total, point, total_point"; $where = "customer_id = ?"; $arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id)); $sqlval = $arrRet[0];
if($sqlval['first_buy_date'] == "") { $sqlval['first_buy_date'] = "Now()"; } $sqlval['last_buy_date'] = "Now()"; $sqlval['buy_times']++; $sqlval['buy_total']+= $arrData['total']; if ( $sqlval['total_point'] != $sqlval['point'] ) { $sqlval_tmp['point'] = $sqlval['total_point']; $sqlval['total_point'] = ($sqlval_tmp['point'] + $arrData['add_point'] - $arrData['use_point']); $sqlval['point'] = ($sqlval['point'] - $arrData['use_point']); } else { $sqlval['total_point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']); $sqlval['point'] = ($sqlval['point'] - $arrData['use_point']); }
// ポイントが不足している場合 if($sqlval['point'] < 0) { $objQuery->rollback(); SC_Utils_Ex::sfDispSiteError(LACK_POINT); }
$objQuery->update("dtb_customer", $sqlval, $where, array($customer_id)); }
LC_Page_Admin_Order_Status.phpを変更。 引用: //ステータス情報の更新(削除) function lfStatusMove($status_id, $arrMove){ $objQuery = new SC_Query(); $masterData = new SC_DB_MasterData_Ex(); $arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
$table = 'dtb_order'; $where = 'order_id = ?'; $arrUpdate = array('update_date' => 'NOW()');
$delflg = '1'; // 削除フラグ $message = ''; // ステータス変更後にポップアップするメッセージの内容
if ( $status_id == 'delete' ) { $arrUpdate['del_flg'] = $delflg; $message = '削除'; } // ステータスが発送済みの時は発送日を更新 elseif ( $status_id == ORDER_DELIV ) { $arrUpdate['status'] = $status_id; $arrUpdate['commit_date'] = 'NOW()'; $message = $arrORDERSTATUS[$status_id] . 'へ移動'; } else { $arrUpdate['status'] = $status_id; $message = $arrORDERSTATUS[$status_id] . 'へ移動'; }
if ( isset($arrMove) ){ foreach ( $arrMove as $val ){ if ( $val != "" ) { $objQuery->update($table, $arrUpdate, $where, array($val)); }
} }
$this->tpl_onload = "window.alert('選択項目を" . $message . "しました。');"; }
上記を下記に変更。 引用: //ステータス情報の更新(削除) function lfStatusMove($status_id, $arrMove){ $objQuery = new SC_Query(); $masterData = new SC_DB_MasterData_Ex(); $arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
$table = 'dtb_order'; $where = 'order_id = ?'; $arrUpdate = array('update_date' => 'NOW()');
$delflg = '1'; // 削除フラグ $message = ''; // ステータス変更後にポップアップするメッセージの内容
if ( $status_id == 'delete' ) { $arrUpdate['del_flg'] = $delflg; $message = '削除'; } // ステータスが発送済みの時は発送日を更新 elseif ( $status_id == ORDER_DELIV ) { $arrUpdate['status'] = $status_id; $arrUpdate['commit_date'] = 'NOW()';
$message = $arrORDERSTATUS[$status_id] . 'へ移動'; } else { $arrUpdate['status'] = $status_id; $message = $arrORDERSTATUS[$status_id] . 'へ移動'; }
if ( isset($arrMove) ){ foreach ( $arrMove as $val ){ if ( $val != "" ) { if ( $status_id == ORDER_DELIV ) { $arrRet = $objQuery->select("customer_id", $table, $where, array($val));
$customer_id = $arrRet[0]['customer_id']; if($customer_id != "" && $customer_id >= 1) { $arrRet = $objQuery->select('total_point', 'dtb_customer', 'customer_id = ?', array($customer_id)); $sqlval['point'] = $arrRet[0]['total_point']; $objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id)); } } $objQuery->update($table, $arrUpdate, $where, array($val)); }
} }
$this->tpl_onload = "window.alert('選択項目を" . $message . "しました。');"; }
ステータスの変更は1件でも、まとめてでもポイント付与できます。 ステータス変更前に注文分の中の商品がキャンセルもしくは全部キャンセルが発生した場合、dtb_customerのtotal_pointを表示させ変更させる必要があるので明日訂正してみます。
|