下記の項目にも対応させました。
・新規会員登録時にウェルカムポイント付与の可否があってもOK。
・顧客管理画面で最終保持ポイントを表示させ、ステータスを発送済みにする前に注文キャンセルなどがあった場合は最終保持ポイント欄からポイントを調整する。元々表示の保持ポイント欄は調整する必要がありません。ポイントを手動で調整する場合は最終保持ポイント欄で調整します。
顧客管理画面の見方↓
顧客管理画面には保持ポイント欄と最終保持ポイント欄があります。注文後、ステータスを発送済みにするとポイントが付与され、必ず、保持ポイント欄と最終保持ポイント欄のポイント数が一致します。
ステータスを発送済みにするまではポイントは付与されません。ポイントを付与する前にお客様が続けて注文してきた場合でも前のポイント分も含めて加算するようになっています。注文時に最終保持ポイントを利用しても、利用分は自動で差し引きします。
変更箇所↓
dtb_customerにフィールド追加。
フィールド名:total_point
LC_Page_Admin_Customer_Edit.phpに追加
108行目に下記追加(元々あれば追加必要なし)
引用:
array( "column" => "total_point", "convert" => "n" ),
330行目に下記追加(元々あれば追加必要なし)
引用:
$objErr->doFunc(array("最終所持ポイント", "total_point", TEL_LEN) ,array("MAX_LENGTH_CHECK", "NUM_CHECK"));
Smarty/templates/default/admin/customer/edit.tplに追加
248行目に下記追加
引用:
<tr class="fs12n">
<td bgcolor="#f2f1ec" width="190">最終所持ポイント</td>
<td bgcolor="#ffffff" width="527"><span class="red12"><!--{$arrErr.total_point}--></span><input type="text"
name="total_point" value="<!--{$list_data.total_point|escape}-->" maxlength="<!--{$smarty.const.TEL_LEN}-->" <!--{if
$arrErr.total_point != ""}--><!--{sfSetErrorStyle}--><!--{/if}--> size="6" class="box6" <!--{if $arrErr.total_point != ""}--
><!--{sfSetErrorStyle}--><!--{/if}--> /> pt</td>
</tr>
Smarty/templates/default/admin/customer/edit_confirm.tplに追加
173行目に下記追加
引用:
<tr class="fs12n">
<td bgcolor="#f2f1ec" width="190">最終所持ポイント</td>
<td bgcolor="#ffffff" width="527"><!--{$arrForm.total_point|escape|default:"0"}--> pt</td>
</tr>
注文完了時にすぐにポイントが付与されないようにLC_Page_Shopping_Complete.phpを変更
引用:
/* 購入情報を会員テーブルに登録する */
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'] ) {
if ( $sqlval['total_point'] == "" ) {
$sqlval['total_point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']);
$sqlval['point'] = ($sqlval['point'] - $arrData['use_point']);
} elseif ( $sqlval['total_point'] < $sqlval['point'] ) {
$sqlval_tmp['point']+= $sqlval['total_point'] + $sqlval['point'];
$sqlval['total_point'] = ($sqlval_tmp['point'] + $arrData['add_point'] - $arrData['use_point']);
$sqlval['point'] = ($sqlval['point'] - $arrData['use_point']);
} else {
$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()');
$col = 'point, total_point';
$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($col, 'dtb_customer', 'customer_id = ?', array($customer_id));
if($arrRet[0]['total_point'] < $arrRet[0]['point']) {
$arrRet[0]['total_point']+= $arrRet[0]['point'];
$sqlval['point'] = $arrRet[0]['total_point'];
$sqlval['total_point'] = $arrRet[0]['total_point'];
$objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id));
} else {
$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 . "しました。');";
}